shapely.get_geometry#

get_geometry(geometry, index, **kwargs)#

Returns the nth geometry from a collection of geometries.

Parameters
geometryGeometry or array_like
indexint or array_like

Negative values count from the end of the collection backwards.

**kwargs

For other keyword-only arguments, see the NumPy ufunc docs.

Notes

  • simple geometries act as length-1 collections

  • out-of-range values return None

Examples

>>> from shapely import Point, MultiPoint
>>> multipoint = MultiPoint([(0, 0), (1, 1), (2, 2), (3, 3)])
>>> get_geometry(multipoint, 1)
<POINT (1 1)>
>>> get_geometry(multipoint, -1)
<POINT (3 3)>
>>> get_geometry(multipoint, 5) is None
True
>>> get_geometry(Point(1, 1), 0)
<POINT (1 1)>
>>> get_geometry(Point(1, 1), 1) is None
True