Add patch_area_min filter and CRS check to dft_rast_transition()#20
Merged
NewGraphEnvironment merged 3 commits intomainfrom Apr 1, 2026
Merged
Add patch_area_min filter and CRS check to dft_rast_transition()#20NewGraphEnvironment merged 3 commits intomainfrom
NewGraphEnvironment merged 3 commits intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
patch_area_minparameter todft_rast_transition(): removes connected patches of changed pixels smaller than a threshold (m²) using 8-connectedterra::patches()$removedelement to return list: factor SpatRaster of filtered-out transitions for visual QAdft_check_crs()internal helper: errors on geographic CRS input, wired intodft_rast_transition()anddft_rast_summarize()\@ref()cross-references, add filtering section with comparison table and 3-panel figureFixes #14
Fixes #15
Fixes #17
Relates to NewGraphEnvironment/sred-2025-2026#16
Test plan
devtools::test()— 166 pass, 0 fail (30 new)🤖 Generated with Claude Code