shapely.get_point

Contents

shapely.get_point#

get_point(geometry, index, **kwargs)#

Returns the nth point of a linestring or linearring.

Parameters:
geometryGeometry or array_like
indexint or array_like

Negative values count from the end of the linestring backwards.

**kwargs

See NumPy ufunc docs for other keyword arguments.

See also

get_num_points

Examples

>>> from shapely import LinearRing, LineString, MultiPoint, Point
>>> line = LineString([(0, 0), (1, 1), (2, 2), (3, 3)])
>>> get_point(line, 1)
<POINT (1 1)>
>>> get_point(line, -2)
<POINT (2 2)>
>>> get_point(line, [0, 3]).tolist()
[<POINT (0 0)>, <POINT (3 3)>]

The functcion works the same for LinearRing input:

>>> get_point(LinearRing([(0, 0), (1, 1), (2, 2), (0, 0)]), 1)
<POINT (1 1)>

For non-linear geometries it returns None:

>>> get_point(MultiPoint([(0, 0), (1, 1), (2, 2), (3, 3)]), 1) is None
True
>>> get_point(Point(1, 1), 0) is None
True