momepy.cds_length¶
-
momepy.cds_length(graph, radius=
5, mode='sum', name='cds_len', degree='degree', length='mm_len', distance=None, verbose=True)[source]¶ Calculates length of cul-de-sacs for subgraph around each node if radius is set, or for whole graph, if
radius=None. A subgraph is generated around each node within set radius. Ifdistance=None, radius will define topological distance, otherwise it uses values in distance attribute.- Parameters:¶
- graph : networkx.Graph¶
A Graph representing a street network. Ideally generated from GeoDataFrame using
momepy.gdf_to_nx().- radius : int | None, optional¶
Include all neighbors of distance <= radius from
n. If None, calculate the metric for the entire graph.- mode : str (default 'sum')¶
If
'sum', calculate total length, if'mean'calculate mean length.- name : str, optional¶
The calculated attribute name.
- degree : str¶
The name of attribute of node degree (
momepy.node_degree()).- length : str, optional¶
The name of the attribute of segment length (geographical).
- distance : str, optional¶
Use specified edge data key as distance. For example, setting
distance=’weight’will use the edgeweightto measure the distance from the noden.- verbose : bool (default True)¶
If
True, shows progress bars in loops and indication of steps.
- Returns:¶
netx (Graph) – A networkx.Graph object if
radiusis set.float – The length of cul-de-sacs for the graph if
radius=None.
Examples
>>> network_graph = mm.cds_length( ... network_graph, radius=9, mode='mean' ... )