geopandas.GeoSeries.explode#
- GeoSeries.explode(ignore_index=False, index_parts=False)[来源]#
将多部分几何体分解为多个单独的几何体。
单行可以变成多行。这类似于PostGIS的ST_Dump()。‘path’索引是返回的MultiIndex的第二级
- Parameters:
- ignore_indexbool, default False
如果为 True,结果索引将标记为 0, 1, …, n - 1,忽略 index_parts。
- index_partsboolean, default False
如果为True,结果索引将是一个多重索引(原始索引加上一个额外的级别,指示多个几何体:每个多部分几何体的每个单一部分几何体都有一个新的零基索引)。
- Returns:
- 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.
另请参阅
示例
>>> from shapely.geometry import MultiPoint >>> s = geopandas.GeoSeries( ... [MultiPoint([(0, 0), (1, 1)]), MultiPoint([(2, 2), (3, 3), (4, 4)])] ... ) >>> s 0 MULTIPOINT ((0 0), (1 1)) 1 MULTIPOINT ((2 2), (3 3), (4 4)) dtype: geometry
>>> s.explode(index_parts=True) 0 0 POINT (0 0) 1 POINT (1 1) 1 0 POINT (2 2) 1 POINT (3 3) 2 POINT (4 4) dtype: geometry