geopandas.GeoSeries.explode

GeoSeries.explode()

Explode multi-part geometries into multiple single geometries.

Single rows can become multiple rows. This is analogous to PostGIS’s ST_Dump(). The ‘path’ index is the second level of the returned MultiIndex

A GeoSeries with a MultiIndex. The levels of the MultiIndex are the original index and a zero-based integer index that counts the number of single geometries within a multi-part geometry.

Examples

>>> from shapely.geometry import MultiPoint
>>> s = geopandas.GeoSeries(
...     [MultiPoint([(0, 0), (1, 1)]), MultiPoint([(2, 2), (3, 3), (4, 4)])]
... )
>>> s
0        MULTIPOINT (0.00000 0.00000, 1.00000 1.00000)
1    MULTIPOINT (2.00000 2.00000, 3.00000 3.00000, ...
dtype: geometry
>>> s.explode()
0  0    POINT (0.00000 0.00000)
   1    POINT (1.00000 1.00000)
1  0    POINT (2.00000 2.00000)
   1    POINT (3.00000 3.00000)
   2    POINT (4.00000 4.00000)
dtype: geometry