geopandas.GeoSeries.explode#

GeoSeries.explode(ignore_index=False, index_parts=None)#

将多零件几何图形分解为多个单一几何图形。

单行可以变成多行。这类似于PostGIS的ST_DUMP()。‘路径’索引是返回的多重索引的第二级

参数
ignore_index布尔值,默认为False

如果为True,则生成的索引将被标记为0,1,…,n-1,忽略 index_parts

index_parts布尔值,默认为True

如果为True,则生成的索引将是多个索引(具有指示多个几何图形的附加级别的原始索引:每个多零件几何图形的每个单个零件几何图形的新索引从零开始)。

退货
具有多重索引的GeoSeries。多重索引的级别是
原始索引和一个从零开始的整数索引
多部分几何图形中的单个几何图形的数量。

示例

>>> 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(index_parts=True)
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