
Apply Rearing-Spawning and Waterbody Connectivity
Source:R/lnk_pipeline_connect.R
lnk_pipeline_connect.RdSixth and final phase of the habitat classification pipeline. Runs
the connectivity logic that frs_habitat() executes internally —
rearing-spawning clustering via fresh::frs_cluster() and
connected-waterbody rules via fresh:::.frs_connected_waterbody()
— configured by per-species flags in loaded$parameters_fresh:
Usage
lnk_pipeline_connect(
conn,
aoi,
cfg,
loaded,
schema,
species = NULL,
thresholds_csv = system.file("extdata", "parameters_habitat_thresholds.csv", package =
"fresh")
)Arguments
- conn
A DBI::DBIConnection object.
- aoi
Character. Watershed group code (kept for signature consistency with the other pipeline phases; not used in this phase — connectivity operates on the classified table which is already AOI-scoped).
- cfg
An
lnk_configobject fromlnk_config().- loaded
Named list of tibbles from
lnk_load_overrides(). Carriesparameters_freshandwsg_species_presence.- schema
Character. Working schema name (kept for signature consistency; connectivity reads
fresh.streams_habitatdirectly).- species
Character vector. Species to run connectivity for. Default derives the same way as
lnk_pipeline_classify().- thresholds_csv
Path to the habitat thresholds CSV. Default uses the copy shipped with fresh.
Details
cluster_rearing— enables three-phase rearing-spawning clustering for the speciescluster_direction,cluster_bridge_gradient,cluster_bridge_distance,cluster_confluence_m— cluster parameterscluster_spawning— enables spawn clustering for rules withrequires_connected: rearing(e.g. SK spawning adjacent to rearing lakes)
Mutates fresh.streams_habitat in place, adjusting spawning /
rearing booleans per species based on connectivity.
lnk_pipeline_connect is a thin wrapper over fresh's internal
.frs_run_connectivity orchestrator. Accessing fresh internals is
an acknowledged fragility — a fresh issue will be filed to export a
stable API for this composition. The wrapper isolates link from the
internal name, so future renames in fresh affect one file here.
Examples
if (FALSE) { # \dontrun{
conn <- lnk_db_conn()
cfg <- lnk_config("bcfishpass")
loaded <- lnk_load_overrides(cfg)
schema <- "working_bulk"
lnk_pipeline_setup(conn, schema)
lnk_pipeline_load(conn, "BULK", cfg, loaded, schema)
lnk_pipeline_prepare(conn, "BULK", cfg, loaded, schema)
lnk_pipeline_break(conn, "BULK", cfg, loaded, schema)
lnk_pipeline_classify(conn, "BULK", cfg, loaded, schema)
lnk_pipeline_connect(conn, "BULK", cfg, loaded, schema)
DBI::dbDisconnect(conn)
} # }