Repository navigation
lnk_score_severity: classify crossings by biological impact #11
Copy link
Copy link
Closed
Description
lnk_score_severity() — classify crossings by biological impact
The core scoring function. Classify crossings into severity levels (high/moderate/low) based on actual crossing measurements rather than the binary BARRIER/PASSABLE provincial classification. Thresholds are configurable per project, species, and life stage.
Signature
lnk_score_severity(
conn,
crossings,
thresholds = lnk_thresholds(),
col_drop = "outlet_drop",
col_slope = "culvert_slope",
col_length = "culvert_length_m",
col_width = "downstream_channel_width",
col_severity = "severity",
to = NULL,
verbose = TRUE
)Parameters
conn— DBI connectioncrossings— schema-qualified crossings table (after overrides applied)thresholds— output oflnk_thresholds(). Named list withhigh,moderate,lowseverity specs.col_drop,col_slope,col_length,col_width— column name parameters. Defaults match PSCIS field names. Users in other systems swap these without touching scoring logic.col_severity— name of the output column written to the crossings tableto— ifNULL, updatescrossingsin-place. If specified, writes scored copy to new table.verbose— report severity distribution
Returns
Updates or creates a table with the col_severity column populated. Returns the table name (invisibly) for piping.
Design intent
- Beyond binary: provincial
barrier_resulttreats very different crossings identically. A 1.2m outlet drop and a 0.3m drop with steep slope are both "BARRIER" but have very different biological impact. - Measurement-based: uses actual culvert dimensions, not just the assessment checkbox. This is the technological uncertainty from SRED — translating measurements into biological impact scores.
- Column-agnostic:
col_drop = "outlet_drop"is the PSCIS default. A New Zealand user might passcol_drop = "perch_height". The scoring logic is identical. - Threshold-driven: all cutoffs come from
lnk_thresholds()— nothing is hardcoded in the function body.
Scoring logic (default thresholds)
| Severity | Criteria | Biological interpretation |
|---|---|---|
| High | outlet_drop >= 0.6m OR (slope > 5% AND length > 25m) | Impassable to most species at most flows |
| Moderate | outlet_drop >= 0.3m OR (slope > 3% AND length > 15m) | Flow-dependent, potentially passable at migration flows |
| Low | everything else with a crossing present | Likely passable for target species at relevant flows |
Examples must show
- Score crossings with default thresholds — show the severity distribution
- Custom thresholds for a project focused on bull trout (higher drop tolerance)
- Column remapping for non-PSCIS data:
col_drop = "perch_height", col_slope = "pipe_gradient" - Full pipeline:
lnk_override_apply()→lnk_score_severity()→lnk_break_source()— the three-step workflow that produces fresh input - Verbose output showing "High: 234, Moderate: 891, Low: 2,103" — users need to see the distribution to validate thresholds
- WHY this matters: show two crossings with same
barrier_result = "BARRIER"but different severity scores
File layout
R/lnk_score_severity.Rtests/testthat/test-lnk_score_severity.R
Relates to #1
Relates to NewGraphEnvironment/sred-2025-2026#24
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Add score family: severity and custom