Repository navigation
Package scope: crossing connectivity interpretation #1
Description
link — Crossing Connectivity Interpretation
Scoring, overrides, and prioritization for fish passage crossings. The domain interpretation layer between raw crossing data and fresh's generic network engine.
Architecture
raw crossing data → link (interpret, score, override) → fresh (segment, classify, aggregate)
modelled crossings severity scoring network segmentation
PSCIS assessments crossing matching habitat classification
override CSVs custom barrier metrics upstream habitat rollup
MOTI chris_culvert_id life-stage context break_sources interface
fresh stays domain-agnostic — it breaks networks at points and classifies segments by attributes. link is the domain expert that understands crossing assessment data and produces the scored tables that fresh consumes.
What link does
1. Override management
Load and apply correction CSVs that refine modelled crossing data:
- Modelled crossing fixes (OBS/NONE from imagery and field review)
- PSCIS barrier status overrides (expert corrections)
- PSCIS-to-modelled crossing xref (GPS/mapping error corrections)
- User-identified barriers and natural barrier corrections
These corrections represent tens of thousands of hand-reviewed crossings accumulated across field seasons and projects.
2. Crossing source integration
Match and link crossing records across data systems:
- PSCIS stream_crossing_id ↔ modelled_crossing_id
- MOTI chris_culvert_id ↔ PSCIS and modelled crossings (not currently linked — significant gap in provincial data integration)
- CABD dam records
- User-identified barriers
3. Severity scoring
Provincial PSCIS scoring uses criteria developed for juvenile salmon and small resident rainbow trout. The barrier_result treats crossings with very different passage characteristics identically.
link introduces severity classification based on actual crossing measurements:
High severity — outlet_drop >= 0.6m, steep long pipes
Moderate severity — flow-dependent, potentially passable at migration
Low severity — likely passable for target species at relevant flows
The thresholds are configurable per project — not hardcoded.
4. Life-stage and species context
Priority hierarchy:
- Adult spawner access to spawning habitat — highest priority
- Juvenile upstream movement for rearing access — secondary
- General connectivity — baseline consideration
5. Output for fresh
Produce break_source-compatible tables:
crossings <- lnk_overrides_apply(conn, crossings)
crossings <- lnk_score_severity(conn, crossings)
frs_habitat(conn, "BULK",
break_sources = list(
list(table = crossings,
label_col = "severity",
label_map = c("high" = "blocked",
"moderate" = "potential"))))Proposed function surface
All exported functions prefixed lnk_:
lnk_overrides_load()— load override CSVslnk_overrides_apply()— apply corrections to crossings tablelnk_match_pscis()— match PSCIS to modelled crossingslnk_match_moti()— link MOTI chris_culvert_id to PSCIS/modelledlnk_score_severity()— classify by biological impactlnk_score_custom()— user-defined scoring ruleslnk_break_source()— produce fresh-compatible break source tablelnk_upstream_habitat()— per-crossing habitat rollup from fresh output
Dependencies
- Runtime: DBI, RPostgres, fresh
- Data: Override CSVs, PSCIS assessment data, modelled crossings, MOTI culvert inventory
- Database: PostgreSQL with fwapg (via fresh connection)
MOTI chris_culvert_id integration
MOTI maintains a culvert inventory with chris_culvert_id that is not currently linked to PSCIS or modelled crossings in the provincial data systems. This is a significant gap — MOTI has condition and dimension data on thousands of crossings that could inform severity scoring. link should establish this linkage.
Relates to
- Apply bcfishpass override CSVs to crossings extract fresh#90 — override CSVs
- Unified network segmentation: frs_network_segment + frs_habitat_classify fresh#83 — unified pipeline
- Replace falls param with break_sources list (label_col + label_map) fresh#70 — break_sources architecture
Activity
Add planning files and create function issues #3–#14
Scaffold link package with core utilities and thresholds
Update planning: phases 1-2 complete
Add vignette, README, NEWS for MORR crossing interpretation
Run vignette on MORR with fresh CSV + bcdata, fix DB tests
Add frs_feature_find + frs_feature_index for network features
Add frs_feature_find + frs_feature_index (#95)
NewGraphEnvironment commentedon Apr 29, 2026
Closing as superseded by the package's evolution. The function surface proposed here (lnk_overrides_load, lnk_match_pscis, lnk_score_severity, lnk_break_source, lnk_upstream_habitat) was a v0.6-era sketch; the actual implementation landed as lnk_load, lnk_match, lnk_score, lnk_source, lnk_aggregate, with the manifest/data split (#65) layering lnk_config + lnk_load_overrides on top. Package scope also broadened beyond crossing connectivity to habitat and connectivity interpretation generally — see DESCRIPTION + README for current framing.
MOTI chris_culvert_id integration mentioned here is still a real gap but warrants its own focused issue when scoped.
Housekeeping: refresh CLAUDE.md + bundle READMEs for v0.18.1
Phase 7 hardening: DDL drift detection + smoke fail-fast + log visibi…
Release v0.36.0: lnk_compare_wsg + parity annotation + 5-host orchest…
v0.40.2: lnk_pipeline_run sizes persist DDL to cfg$species (#194) (#195)