shapely.length#

length(geometry, **kwargs)#

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

Parameters
geometryGeometry or array_like
**kwargs

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

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