Last active
December 12, 2024 23:31
-
-
Save mhweber/21b44773b3b44b61145a7ddc1ccf0ca2 to your computer and use it in GitHub Desktop.
Fill holes inside polygons
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
basins <- read_sf('mybasins.shp') | |
library(smoothr) | |
mapview(basins[basins$SITE_ID =='ID',]) | |
area_thresh <- units::set_units(100, km^2) | |
unique(st_geometry_type(basins$Shape)) | |
oddballs <- basins |> | |
dplyr::filter(!grepl("POLYGON", st_geometry_type(Shape)) | !grepl("MULTIPOLYGON", st_geometry_type(Shape))) | |
basins <- smoothr::fill_holes(basins, threshold = area_thresh) | |
mapview(basins[basins$SITE_ID =='ID',]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment