Skip to contents

Second phase of the habitat classification pipeline. Loads the anthropogenic crossing table for an AOI and applies the two crossing-level override types from the config bundle:

Usage

lnk_pipeline_load(conn, aoi, cfg, loaded, schema)

Arguments

conn

A DBI::DBIConnection object (localhost fwapg, typically from lnk_db_conn()).

aoi

Character. Today accepts a watershed group code (e.g. "BULK"). Filtering against watershed_group_code columns in the CSVs means polygon / ltree AOIs are not yet supported here; those will come as a follow-up.

cfg

An lnk_config object from lnk_config().

loaded

Named list of tibbles from lnk_load_overrides(). Carries the override CSVs (user_crossings_misc, user_modelled_crossing_fixes, user_pscis_barrier_status) this phase needs.

schema

Character. Working schema name (validated). Must already exist — call lnk_pipeline_setup() first.

Value

conn invisibly, for pipe chaining.

Details

  1. Modelled crossing fixes — imagery/field corrections where structure = "NONE" or structure = "OBS" force the crossing's barrier_status to "PASSABLE". These are modelled culverts that, on inspection, turned out to be open channels or observation-only points.

  2. PSCIS barrier status overrides — expert-curated user_barrier_status values replace the modelled barrier_status for a PSCIS crossing.

The barrier_status column on <schema>.crossings is the bcfishpass-parity label — {PASSABLE, POTENTIAL, BARRIER, UNKNOWN} — derived from PSCIS field current_barrier_result_code plus the override CSV. It is distinct from severity produced by lnk_score() (link's own culvert-geometry scoring; high / moderate / low). Both can coexist on the same crossings row: barrier_status for parity comparisons against bcfp, severity for link-specific metrics and break-source label translation via lnk_source().

Falls, user-identified definite barriers, observation exclusions, and habitat classification CSVs are loaded by lnk_pipeline_prepare() where they are consumed, not here.

Writes to these tables under the caller's working schema:

  • <schema>.crossings — base crossings + misc crossings, with overridden barrier_status applied

  • <schema>.crossing_fixes — modelled fixes for the AOI (only when the config bundle has fixes matching this AOI)

  • <schema>.pscis_fixes — PSCIS status overrides for the AOI (only when the config bundle has entries matching this AOI)

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, aoi = "BULK", cfg = cfg, loaded = loaded,
                  schema = schema)

# Inspect the result
DBI::dbGetQuery(conn, sprintf(
  "SELECT barrier_status, count(*) FROM %s.crossings GROUP BY 1", schema))

DBI::dbDisconnect(conn)
} # }