geopandas.GeoSeries.length#

property GeoSeries.length#

返回一个 Series 包含以CRS为单位表示的每个几何图形的长度。

对于(多)多边形,它测量其外部的长度(即周长)。

参见

GeoSeries.area

测量多边形的面积

注意事项

长度对于以度为单位的地理CRS可能无效;请使用 GeoSeries.to_crs() 在使用此函数之前,将几何图形投影到平面CRS。

GeoPandas中的每个操作都是平面的,即没有考虑潜在的第三维。

示例

>>> 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.00000 0.00000, 1.00000 1.00000, ...
1    LINESTRING (10.00000 0.00000, 10.00000 5.00000...
2    MULTILINESTRING ((0.00000 0.00000, 1.00000 0.0...
3    POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....
4                              POINT (0.00000 1.00000)
5    GEOMETRYCOLLECTION (POINT (1.00000 0.00000), L...
dtype: geometry
>>> s.length
0     2.414214
1    16.180340
2     3.000000
3     3.414214
4     0.000000
5    16.180340
dtype: float64