Removes (sets to 0) cells in a binary raster that overlap with any
exclusion mask. Useful for trimming floodplain by urban areas, steep
terrain, waterbodies, or other features.
Examples
slope <- terra::rast(system.file("testdata/slope.tif", package = "flooded"))
gentle <- fl_mask(slope, threshold = 9, operator = "<=")
# Trim: remove cells on slopes > 5% (a stricter exclusion mask)
steep <- fl_mask(slope, threshold = 5, operator = ">")
trimmed <- fl_flood_trim(gentle, steep)
terra::plot(trimmed, col = c("grey90", "darkgreen"), main = "Trimmed by steep slopes")
