View source: R/filter_islands.R
ms_filter_islands | R Documentation |
Remove small detached polygons, keeping those with a minimum area and/or a minimum number of vertices. Optionally remove null geometries.
ms_filter_islands(
input,
min_area = NULL,
min_vertices = NULL,
drop_null_geometries = TRUE,
...
)
input |
spatial object to filter. One of:
|
min_area |
minimum area of polygons to retain. Area is calculated using planar geometry, except for the area of unprojected polygons, which is calculated using spherical geometry in units of square meters. |
min_vertices |
minimum number of vertices in polygons to retain. |
drop_null_geometries |
should features with empty geometries be dropped?
Default |
... |
Arguments passed on to
|
object with only specified features retained, in the same class as the input
library(geojsonsf)
library(sf)
poly <- structure("{\"type\":\"FeatureCollection\",
\"features\":[{\"type\":\"Feature\",\"properties\":{},
\"geometry\":{\"type\":\"Polygon\",
\"coordinates\":[[[102,2],[102,4],[104,4],[104,2],[102,2]]]}},
{\"type\":\"Feature\",\"properties\":{},
\"geometry\":{\"type\":\"Polygon\",
\"coordinates\":[[[100,2],[98,4],[101.5,4],[100,2]]]}},
{\"type\":\"Feature\",\"properties\":{},
\"geometry\":{\"type\":\"Polygon\",
\"coordinates\":[[[100,0],[100,1],[101,1],[101,0],[100,0]]]}}]}",
class = c("geojson", "json"))
poly <- geojson_sf(poly)
plot(poly)
out <- ms_filter_islands(poly, min_area = 12391399903)
plot(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.