Skip to content

Unified pipeline: frs_network_segment + frs_habitat_classify#88

Merged
NewGraphEnvironment merged 1 commit intomainfrom
network-segment
Apr 6, 2026
Merged

Unified pipeline: frs_network_segment + frs_habitat_classify#88
NewGraphEnvironment merged 1 commit intomainfrom
network-segment

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

Two new exported functions for the unified pipeline (#83):

  • frs_network_segment() — domain-agnostic network segmentation. Extracts, enriches, breaks at any number of sources, assigns id_segment. One table, one copy of geometry, shared across species.

  • frs_habitat_classify() — long-format habitat classification. One row per segment x species. Species-specific accessibility via break label filtering (gradient_15 blocks CO but not BT).

Also: .frs_sql_num() for locale-safe numeric SQL, auto-indexing on label, id_segment, species_code.

Output structure

fresh.streams         — 19,048 segments (geometry, once)
fresh.streams_habitat — 57,144 rows (3 species x segments, no geometry)
fresh.streams_breaks  — enriched breaks with ltree codes + labels

Species-specific accessibility

Species Access threshold Accessible segments
CO 15% 3,719
ST 20% 5,139
BT 25% 7,219

Test plan

  • devtools::test() — 528 pass, 0 fail
  • Code review — 2 rounds, locale fix applied
  • End-to-end: barriers → segment → classify on ADMS
  • Multi-threshold accessibility verified (CO < ST < BT)
  • id_segment unique across all segments

Fixes #83
Relates to #82, #86
Relates to NewGraphEnvironment/sred-2025-2026#16

🤖 Generated with Claude Code

frs_network_segment: domain-agnostic network segmentation. Extracts
base streams, enriches with channel width, assigns id_segment, applies
break sources, recomputes gradient from new geometry. One table, one
copy of geometry, shared across species.

frs_habitat_classify: long-format habitat classification. One row per
segment x species with accessible/spawning/rearing/lake_rearing.
Species-specific accessibility via label filtering — gradient_15 blocks
CO but not BT; gradient_25 blocks both.

Tested: ADMS with 3 access thresholds (15/20/25%), 3 species.
CO: 3,719 accessible. ST: 5,139. BT: 7,219.
19,048 segments x 3 species = 57,144 habitat rows, geometry stored once.

Also: .frs_sql_num() for locale-safe numeric SQL, auto-index on
label/id_segment/species_code columns.

Fixes #83
Relates to #82, #86

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NewGraphEnvironment NewGraphEnvironment merged commit 9558757 into main Apr 6, 2026
1 check passed
@NewGraphEnvironment NewGraphEnvironment deleted the network-segment branch April 6, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified network segmentation: frs_network_segment + frs_habitat_classify

1 participant