dask_geopandas.GeoSeries.explode

dask_geopandas.GeoSeries.explode#

GeoSeries.explode()#

Explode multi-part geometries into multiple single geometries.

This docstring was copied from geopandas.geodataframe.GeoDataFrame.explode.

Some inconsistencies with the Dask version may exist.

Each row containing a multi-part geometry will be split into multiple rows with single geometries, thereby increasing the vertical size of the GeoDataFrame.

Parameters:
columnstring, default None (Not supported in Dask)

Column to explode. In the case of a geometry column, multi-part geometries are converted to single-part. If None, the active geometry column is used.

ignore_indexbool, default False (Not supported in Dask)

If True, the resulting index will be labelled 0, 1, …, n - 1, ignoring index_parts.

index_partsboolean, default True (Not supported in Dask)

If True, the resulting index will be a multi-index (original index with an additional level indicating the multiple geometries: a new zero-based index for each single part geometry per multi-part geometry).

Returns:
GeoDataFrame

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(index_parts=True)  
>>> 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)
>>> exploded = gdf.explode(index_parts=False)  
>>> exploded  
    col1                 geometry
0  name1  POINT (1.00000 2.00000)
0  name1  POINT (3.00000 4.00000)
1  name2  POINT (2.00000 1.00000)
1  name2  POINT (0.00000 0.00000)
>>> exploded = gdf.explode(ignore_index=True)  
>>> exploded  
    col1                 geometry
0  name1  POINT (1.00000 2.00000)
1  name1  POINT (3.00000 4.00000)
2  name2  POINT (2.00000 1.00000)
3  name2  POINT (0.00000 0.00000)