Skip to content

lnk_score_severity: classify crossings by biological impact #11

Closed

Description

@NewGraphEnvironment

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 connection
  • crossings — schema-qualified crossings table (after overrides applied)
  • thresholds — output of lnk_thresholds(). Named list with high, moderate, low severity 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 table
  • to — if NULL, updates crossings in-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_result treats 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 pass col_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

  1. Score crossings with default thresholds — show the severity distribution
  2. Custom thresholds for a project focused on bull trout (higher drop tolerance)
  3. Column remapping for non-PSCIS data: col_drop = "perch_height", col_slope = "pipe_gradient"
  4. Full pipeline: lnk_override_apply() → lnk_score_severity() → lnk_break_source() — the three-step workflow that produces fresh input
  5. Verbose output showing "High: 234, Moderate: 891, Low: 2,103" — users need to see the distribution to validate thresholds
  6. WHY this matters: show two crossings with same barrier_result = "BARRIER" but different severity scores

File layout

  • R/lnk_score_severity.R
  • tests/testthat/test-lnk_score_severity.R

Relates to #1
Relates to NewGraphEnvironment/sred-2025-2026#24

Activity

  1. added a commit that references this issue on Apr 7, 2026
    a857df9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions