momepy.linearity#
- momepy.linearity(geometry)[source]#
Calculates the linearity of each LineString
The linearity is defined as the ratio of the length of the segment between the first and last point to the length of the LineString. While other geometry types are accepted, the result is not well defined.
\[\frac{l_{euclidean}}{l_{segment}}\]where l is the length of the LineString.
Adapted from [Araldi and Fusco, 2019].
- Parameters:
- geometryGeoDataFrame | GeoSeries
A GeoDataFrame or GeoSeries containing lines to analyse.
- Returns:
- Series
Examples
>>> path = momepy.datasets.get_path("bubenec") >>> streets = geopandas.read_file(path, layer="streets") >>> momepy.linearity(streets).head() 0 1.000000 1 0.995987 2 0.999653 3 0.999997 4 1.000000 dtype: float64