geopandas.GeoSeries.length#

property GeoSeries.length[source]#

Returns a Series containing the length of each geometry expressed in the units of the CRS.

In the case of a (Multi)Polygon it measures the length of its exterior (i.e. perimeter).

See also

GeoSeries.area

measure area of a polygon

Notes

Length may be invalid for a geographic CRS using degrees as units; use GeoSeries.to_crs() to project geometries to a planar CRS before using this function.

Every operation in GeoPandas is planar, i.e. the potential third dimension is not taken into account.

Examples

>>> from shapely.geometry import Polygon, LineString, MultiLineString, Point, GeometryCollection
>>> s = geopandas.GeoSeries(
...     [
...         LineString([(0, 0), (1, 1), (0, 1)]),
...         LineString([(10, 0), (10, 5), (0, 0)]),
...         MultiLineString([((0, 0), (1, 0)), ((-1, 0), (1, 0))]),
...         Polygon([(0, 0), (1, 1), (0, 1)]),
...         Point(0, 1),
...         GeometryCollection([Point(1, 0), LineString([(10, 0), (10, 5), (0, 0)])])
...     ]
... )
>>> s
0                           LINESTRING (0 0, 1 1, 0 1)
1                         LINESTRING (10 0, 10 5, 0 0)
2            MULTILINESTRING ((0 0, 1 0), (-1 0, 1 0))
3                       POLYGON ((0 0, 1 1, 0 1, 0 0))
4                                          POINT (0 1)
5    GEOMETRYCOLLECTION (POINT (1 0), LINESTRING (1...
dtype: geometry
>>> s.length
0     2.414214
1    16.180340
2     3.000000
3     3.414214
4     0.000000
5    16.180340
dtype: float64