Polygonizes a binary (0/1) valley raster, returning an sf polygon layer.
Valley cells (1) are dissolved into contiguous polygons; non-valley cells
are dropped. This is the natural final step after fl_valley_confine().
Arguments
- x
A
SpatRasterwith binary values (0/1), typically the output offl_valley_confine().- dissolve
Logical. If
TRUE(default), adjacent valley cells are dissolved into multipolygon features. IfFALSE, each contiguous patch is a separate polygon.
Examples
dem <- terra::rast(system.file("testdata/dem.tif", package = "flooded"))
slope <- terra::rast(system.file("testdata/slope.tif", package = "flooded"))
gentle <- fl_mask(slope, threshold = 9, operator = "<=")
poly <- fl_valley_poly(gentle)
terra::plot(dem, main = "Gentle slopes as polygons")
plot(sf::st_geometry(poly), add = TRUE, col = "#00800040", border = "darkgreen")
