shapely.length

Contents

shapely.length#

length(geometry, **kwargs)#

Computes the length of a (multi)linestring or polygon perimeter.

Parameters:
geometryGeometry or array_like
**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from shapely import LineString, MultiLineString, Polygon
>>> length(LineString([(0, 0), (0, 2), (3, 2)]))
5.0
>>> length(MultiLineString([
...     LineString([(0, 0), (1, 0)]),
...     LineString([(1, 0), (2, 0)])
... ]))
2.0
>>> length(Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)]))
40.0
>>> length(LineString())
0.0
>>> length(None)
nan