
Build habitat eligibility rules YAML from dimensions CSV
Source:R/lnk_rules_build.R
lnk_rules_build.RdTransforms a species habitat dimensions CSV into the rules YAML format
consumed by fresh::frs_habitat(). The CSV is the human-edited source
of truth; the YAML is the derived artifact.
Usage
lnk_rules_build(
csv,
to,
thresholds = system.file("extdata", "parameters_habitat_thresholds.csv", package =
"fresh"),
edge_types = c("categories", "explicit")
)Arguments
- csv
Path to a dimensions CSV with columns:
species,spawn_lake,spawn_stream,rear_lake,rear_lake_only,rear_no_fw,rear_stream,rear_wetland. Optional columns:river_skip_cw_min(yes/no — skip channel_width_min on river polygon segments),notes.rear_lake_connected_distance_max/rear_wetland_connected_distance_max(metres) keep a species' lake / wetland rearing bucket only where same-species spawning lies within that distance (requires_connected: spawningon its first rear L / W rule). The additive lake rule admits lake centrelines (FWA construction lines) with no channel-width test.rear_wetland_flow(stream,gradientorfree; blank isfree) sets how flow through a wetland (FWA 1050 / 1150) rears:streamemits a rule that inherits the species' gradient, size and near-river thresholds as the stream rule does,gradienta rule with the rear gradient only,freea rule with no test.rear_near_river(both,streamorwetland_flow; blank isboth) sets which rear rules take the species' near-river pair. The pair's numbers live in the thresholds CSV (<stage>_river_*) and fresh inherits them; this function writes no numbers, onlynear_river: falseon the rules outside the scope and on every river-polygon rule, because a river polygon is the river. Seeconfigs/dictionary_dimensions.csvfor every column.- to
Path to write the output YAML.
- thresholds
Path to the habitat thresholds CSV (from fresh). Used to look up
rear_lake_ha_minper species, andrear_gradient_maxfor arear_wetland_flow = gradientrule. Default uses the copy shipped with fresh.- edge_types
Character. How to express stream edge types in rules:
"categories"(default) uses fresh categories (stream,canal)."explicit"uses integer FWA edge_type codes (1000, 1100, 2000, 2300).
Examples
if (FALSE) { # \dontrun{
# NGE defaults
lnk_rules_build(
csv = system.file("extdata", "parameters_habitat_dimensions.csv", package = "link"),
to = "inst/extdata/parameters_habitat_rules.yaml"
)
# bcfishpass comparison variant
lnk_rules_build(
csv = system.file("extdata", "configs", "bcfishpass", "dimensions.csv",
package = "link"),
to = "inst/extdata/configs/bcfishpass/rules.yaml",
edge_types = "explicit"
)
} # }