
Load Crossings and Apply Crossing-Level Overrides
Source:R/lnk_pipeline_load.R
lnk_pipeline_load.RdSecond 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:
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 againstwatershed_group_codecolumns in the CSVs means polygon / ltree AOIs are not yet supported here; those will come as a follow-up.- cfg
An
lnk_configobject fromlnk_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.
Details
Modelled crossing fixes — imagery/field corrections where
structure = "NONE"orstructure = "OBS"force the crossing'sbarrier_statusto"PASSABLE". These are modelled culverts that, on inspection, turned out to be open channels or observation-only points.PSCIS barrier status overrides — expert-curated
user_barrier_statusvalues replace the modelledbarrier_statusfor 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 overriddenbarrier_statusapplied<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)
} # }