Works for multipolygon simple features (see package `sf`) only.

unnest_sf(data, ...)

Arguments

data

data set

...

one or more columns to extract (one is tested, you're on your own with multiple)

Examples

library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, PROJ 4.9.3
nc <- st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source `/Library/Frameworks/R.framework/Versions/3.5/Resources/library/sf/shape/nc.shp' using driver `ESRI Shapefile' #> Simple feature collection with 100 features and 14 fields #> geometry type: MULTIPOLYGON #> dimension: XY #> bbox: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 #> epsg (SRID): 4267 #> proj4string: +proj=longlat +datum=NAD27 +no_defs
gnc <- unnest_sf(nc, geometry) gnc %>% ggplot(aes(x = long, y = lat, group = group)) + geom_polygon()