Skip to content

Add dft_transition_vectors() for exploded change patches#21

Merged
NewGraphEnvironment merged 1 commit intomainfrom
18-transition-vectors
Apr 2, 2026
Merged

Add dft_transition_vectors() for exploded change patches#21
NewGraphEnvironment merged 1 commit intomainfrom
18-transition-vectors

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

  • New exported function dft_transition_vectors() vectorizes a transition SpatRaster into sf polygons — one row per connected patch of pixels sharing the same transition type
  • Supports optional zones parameter for spatial attribution (sub-basins, parcels, management units — any sf polygon set)
  • Supports patch_area_min for filtering small patches before returning
  • Returns patch_id, transition, area_ha, and optional zone column
  • 13 new tests covering structure, area consistency, zone attribution, filtering, and input validation

Fixes #18
Relates to NewGraphEnvironment/sred-2025-2026#16

Test plan

  • devtools::test() — 179 pass, 0 fail (13 new)
  • Total vector area matches raster summary area
  • Patch IDs are unique, transition labels valid
  • Zone attribution and patch_area_min filtering work
  • Input validation: non-SpatRaster, non-factor, geographic CRS, missing zone_col

🤖 Generated with Claude Code

Vectorizes a transition SpatRaster into sf polygons — one row per
connected patch of pixels sharing the same transition type. Supports
optional zone attribution via st_intersection and minimum patch area
filtering. 13 new tests.

Fixes #18

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NewGraphEnvironment NewGraphEnvironment merged commit 20805b9 into main Apr 2, 2026
1 check passed
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.

Add dft_transition_vectors() for exploded change patches with spatial attribution

1 participant