momepy.node_density¶
-
momepy.node_density(graph, radius, length=
'mm_len', distance=None, verbose=True)[source]¶ Calculate the density of a nodes on the street network defined in
graph.Density is calculated 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 indistanceattribute.Calculated as the number of neighbouring nodes / cumulative length of street network (or a subgraph). Returns two values - an unweighted and weighted density unweighted is calculated based on the number of neigbhouring nodes, whereas weighted density will take into account node degree as
k-1.Adapted from [Dibble et al., 2017].
Calculates connectivity gamma index
- 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 metrics for the entire graph.- length=
'mm_len'¶ 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 nodenduringego_graphgeneration.- 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.(unweighted, wieghted) (tuple) – A tuple of floats if
radiusisNone.
Examples
>>> network_graph = mm.node_density(network_graph, radius=5)