I am looking for the equivalent of "Convert multipart features to multiple singlepart features. Creates simple polygons and lines" in QGIS and similar in ArcGIS for R. Various analyses create multipart features (in class sf, they are in the class MULTIPOLYGON or MULTILINESTRING) when the desired output is a simple polygons or simple lines (in class sf, they are in the class POLYGON or LINESTRING)

2 Answers 2


If you are using the sf classes then you cast it from MULTIPOLYGON to POLYGON. Example using data from spData package:

ncsf = st_read(system.file("shapes/sids.shp", package = "spData")[1])
> dim(ncsf)
[1] 100  23

100 features there. Some are MULTIPOLYGON, so let's split:

> ncmp = st_cast(ncsf,"POLYGON")
Warning message:
In st_cast.sf(ncsf, "POLYGON") :
  repeating attributes for all sub-geometries for which they may not be constant

And now we have:

> dim(ncmp)
[1] 108  23

more features.

The warning is just to note that if you split features then things like "population" might not be appropriate to copy across split features (but "population density" might be...)

If you are using sp classes I would say "use sf classes", and if you can't use sf classes for your work I would say "convert to sf, then split, then convert back to sp classes".

#convert sf to sp for use with other functions
ncsf_sp<-as(ncsf, "Spatial")
#convert sp to sf for use with this function 
ncsf_sp<-as(ncsf_sp, "sf")
  • 1
    To add to this, I've discovered the hard way that lwgeom::st_make_valid() followed by st_cast() all to MULTIPOLYGON and then finally st_cast() all to POLYGON can be the only safe method of preserving all geometries in some cases - especially when converting data that's come out of ESRI File Geodatabases.
    – obrl_soil
    Dec 11, 2018 at 21:20
  • 2
    If your analyses somehow turned your polygons into class GEOMETRYCOLLECTION (you'll find this out because you get an error message), it may be necessary to first cast to MULTIPOLYGON before casting to POLYGON. This can be done in one line: st_cast(ncsf, "MULTIPOLYGON" ) %>% st_cast("POLYGON") Jan 25, 2019 at 14:44
  • I want to split only one polygon into its constituents while leaving the other multipolygon features as is. Is that achievable using sf::st_cast() ?? Mar 6, 2023 at 13:37

When using the sp class, there are two functions that explode multipart features into single part features.

  1. ms_explode from rmapshaper which works for multipart polygons and multipart lines but not for SpatialMultiPoints as described in the help file for feature.

  2. disaggregate from sp also splits into single parts but I have found situations where it leads to an error (stating an rgeos error with sp feature) when the same feature converted to sf could be split using st_cast. While I don't understand the behaviour, I have noticed that it can be unstable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.