Skip to contents

Sixth 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_config object from lnk_config().

loaded

Named list of tibbles from lnk_load_overrides(). Carries parameters_fresh and wsg_species_presence.

schema

Character. Working schema name (kept for signature consistency; connectivity reads fresh.streams_habitat directly).

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.

Value

conn invisibly, for pipe chaining.

Details

  • cluster_rearing — enables three-phase rearing-spawning clustering for the species

  • cluster_direction, cluster_bridge_gradient, cluster_bridge_distance, cluster_confluence_m — cluster parameters

  • cluster_spawning — enables spawn clustering for rules with requires_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)
} # }