momepy.
SegmentsLength
(gdf, spatial_weights=None, mean=False)[source]¶Calculate the cummulative and/or mean length of segments.
Length of segments within set topological distance from each of them. Reached topological distance should be captured by spatial_weights. If mean=False it will compute sum of length, if mean=True it will compute sum and mean.
GeoDataFrame containing streets (edges) to analyse
spatial weights matrix  If None, Queen contiguity matrix will be calculated based on streets (note: spatial_weights shoud be based on index, not unique ID).
If mean=False it will compute sum of length, if mean=True it will compute sum and mean
Examples
>>> streets_df['length_neighbours'] = mm.SegmentsLength(streets_df, mean=True).mean
Calculating spatial weights...
Spatial weights ready...
Series containing resulting total lengths
Series containing resulting total lengths
Series containing resulting total lengths
original GeoDataFrame
spatial weights matrix
__init__
(self, gdf, spatial_weights=None, mean=False)[source]¶Initialize self. See help(type(self)) for accurate signature.
Methods

Initialize self. 