Skip to content

Add patch_area_min filter and CRS check to dft_rast_transition()#20

Merged
NewGraphEnvironment merged 3 commits intomainfrom
14-patch-area-filter
Apr 1, 2026
Merged

Add patch_area_min filter and CRS check to dft_rast_transition()#20
NewGraphEnvironment merged 3 commits intomainfrom
14-patch-area-filter

Conversation

@NewGraphEnvironment
Copy link
Copy Markdown
Owner

Summary

  • Add patch_area_min parameter to dft_rast_transition(): removes connected patches of changed pixels smaller than a threshold (m²) using 8-connected terra::patches()
  • Add $removed element to return list: factor SpatRaster of filtered-out transitions for visual QA
  • Add dft_check_crs() internal helper: errors on geographic CRS input, wired into dft_rast_transition() and dft_rast_summarize()
  • Update vignette: fix broken \@ref() cross-references, add filtering section with comparison table and 3-panel figure

Fixes #14
Fixes #15
Fixes #17
Relates to NewGraphEnvironment/sred-2025-2026#16

Test plan

  • devtools::test() — 166 pass, 0 fail (30 new)
  • Vignette renders with comparison table and 3-panel figure
  • Existing tests unchanged in behavior (backward compatible)

🤖 Generated with Claude Code

NewGraphEnvironment and others added 3 commits April 1, 2026 16:01
Internal helper that errors when a raster uses geographic CRS (degrees),
since area calculations via prod(terra::res()) assume metre units. Wired
into dft_rast_summarize(). Also called from dft_rast_transition() (next
commit). 7 new tests.

Fixes #15

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New parameter removes connected patches of changed pixels smaller than a
threshold (m²) using 8-connected terra::patches(). Filters classification
noise from field-forest edges, seasonal canopy variation, and channel
migration artifacts. Default NULL preserves current behavior.

Also wires dft_check_crs() into both r_from and r_to inputs.
Returns $removed SpatRaster of filtered-out transitions for visual QA
(NULL when no filtering applied). 23 new tests.

Fixes #14
Fixes #17

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace broken bookdown @ref() cross-references with natural language.
Add Filtering Classification Noise section demonstrating patch_area_min
with comparison table and 3-panel figure (unfiltered / removed / filtered).

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

1 participant