# momepy.SegmentsLength#

class momepy.SegmentsLength(gdf, spatial_weights=None, mean=False, verbose=True)[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.

Parameters:
gdfGeoDataFrame

A GeoDataFrame containing streets (edges) to analyse.

spatial_weightslibpysal.weights, optional

A spatial weights matrix. If `None`, Queen contiguity matrix will be calculated based on streets.

meanbool, optional
If `mean=False` it will compute sum of length, if `mean=True`

it will compute sum and mean.

verbosebool (default True)

If `True`, shows progress bars in loops and indication of steps.

Notes

The `spatial_weights` keyword argument should be based on index, not unique ID.

Examples

```>>> streets_df['length_neighbours'] = mm.SegmentsLength(streets_df, mean=True).mean
Calculating spatial weights...
```
Attributes:
seriesSeries

A Series containing resulting total lengths.

meanSeries

A Series containing resulting total lengths.

sumSeries

A Series containing resulting total lengths.

gdfGeoDataFrame

The original GeoDataFrame

swlibpysal.weights

The spatial weights matrix.

__init__(gdf, spatial_weights=None, mean=False, verbose=True)[source]#

Methods

 `__init__`(gdf[, spatial_weights, mean, verbose])
{"ft_lang_label":"__label__en","ft_lang_prob":0.6969721,"math_prob":0.94091135,"size":1399,"snap":"2023-14-2023-23","text_gpt3_token_len":327,"char_repetition_ratio":0.13405018,"word_repetition_ratio":0.12,"special_character_ratio":0.19942816,"punctuation_ratio":0.18666667,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99852043,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-02T09:37:50Z\",\"WARC-Record-ID\":\"<urn:uuid:c21e2466-20e8-4791-aae4-2c7ca236806f>\",\"Content-Length\":\"39284\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7bbf64f5-d8e6-4ad6-a6b4-757bc1f44f32>\",\"WARC-Concurrent-To\":\"<urn:uuid:85dc9a34-547d-4d85-8638-c493e02ed797>\",\"WARC-IP-Address\":\"104.17.32.82\",\"WARC-Target-URI\":\"https://docs.momepy.org/en/stable/generated/momepy.SegmentsLength.html\",\"WARC-Payload-Digest\":\"sha1:WVGKB3FIMDX5HLAA5XPAURXE6E3LZN2X\",\"WARC-Block-Digest\":\"sha1:7KMMTMWWN427NW5RRTMOAO3L4MRRMOS7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224648465.70_warc_CC-MAIN-20230602072202-20230602102202-00137.warc.gz\"}"}