shapely.get_parts#
- get_parts(geometry, return_index=False)#
Get parts of each GeometryCollection or Multi* geometry object.
A copy of each geometry in the GeometryCollection or Multi* geometry object is returned.
Note: This does not return the individual parts of Multi* geometry objects in a GeometryCollection. You may need to call this function multiple times to return individual parts of Multi* geometry objects in a GeometryCollection.
- Parameters:
- geometryGeometry or array_like
Geometry or geometries to get the parts of.
- return_indexbool, default False
If True, will return a tuple of ndarrays of (parts, indexes), where indexes are the indexes of the original geometries in the source array.
- Returns:
- ndarray of parts or tuple of (parts, indexes)
See also
Examples
>>> from shapely import MultiPoint >>> get_parts(MultiPoint([(0, 1), (2, 3)])).tolist() [<POINT (0 1)>, <POINT (2 3)>] >>> parts, index = get_parts([MultiPoint([(0, 1)]), MultiPoint([(4, 5), (6, 7)])], return_index=True) >>> parts.tolist() [<POINT (0 1)>, <POINT (4 5)>, <POINT (6 7)>] >>> index.tolist() [0, 1, 1]