GeoDataFrame.
explode
Explode muti-part geometries into multiple single geometries.
Each row containing a multi-part geometry will be split into multiple rows with single geometries, thereby increasing the vertical size of the GeoDataFrame.
The index of the input geodataframe is no longer unique and is replaced with a multi-index (original index with additional level indicating the multiple geometries: a new zero-based index for each single part geometry per multi-part geometry).
Exploded geodataframe with each single geometry as a separate entry in the geodataframe.
See also
GeoDataFrame.dissolve
dissolve geometries into a single observation.
Examples
>>> from shapely.geometry import MultiPoint >>> d = { ... "col1": ["name1", "name2"], ... "geometry": [ ... MultiPoint([(1, 2), (3, 4)]), ... MultiPoint([(2, 1), (0, 0)]), ... ], ... } >>> gdf = geopandas.GeoDataFrame(d, crs=4326) >>> gdf col1 geometry 0 name1 MULTIPOINT (1.00000 2.00000, 3.00000 4.00000) 1 name2 MULTIPOINT (2.00000 1.00000, 0.00000 0.00000)
>>> exploded = gdf.explode() >>> exploded col1 geometry 0 0 name1 POINT (1.00000 2.00000) 1 name1 POINT (3.00000 4.00000) 1 0 name2 POINT (2.00000 1.00000) 1 name2 POINT (0.00000 0.00000)