Explodes multipart features into single part

explode(x, sp = FALSE)

Arguments

x

sp or sf multipart (MULTIPOLYGON, MULTIPOINT, MULTILINE) object

sp

(FALSE/TRUE) output as sp class object, else is sf class

Value

A single part sp or sf object (polygons or points)

Note

Multipart geometries are a data structure where a single attribute shares multiple features (polygons, points, lines). This function dissaggregates the data into a one-to-one match.

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

# \donttest{ library(sf) library(sp) dim( p.sf <- st_read(system.file("shapes/sids.shp", package = "spData")[1]) )
#> Reading layer `sids' from data source `C:\Program Files\R\R-4.0.5\library\spData\shapes\sids.shp' using driver `ESRI Shapefile' #> Simple feature collection with 100 features and 22 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 #> CRS: NA
#> [1] 100 23
dim( p.sf <- explode(p.sf) )
#> Converting multipart MULTIPOLYGON to single part POLYGON
#> [1] 108 23
# }