shapely.get_point

Contents

shapely.get_point#

get_point(geometry, index, **kwargs)#

Return the nth point of a linestring or linearring.

Parameters:
geometryGeometry or array_like

Geometry or geometries to get the point of.

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

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

The function works the same for LinearRing input:

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

For non-linear geometries it returns None:

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