momepy.node_density#
- momepy.node_density(graph, radius, length='mm_len', distance=None, verbose=True)[source]#
Calculate the density of a node’s neighbours (for all nodes) on the street network defined in
graph
.Calculated as the number of neighbouring nodes / cumulative length of street network within neighbours. 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].
- Parameters:
- graphnetworkx.Graph
A Graph representing a street network. Ideally generated from GeoDataFrame using
momepy.gdf_to_nx()
.- radius: int
Include all neighbors of distance <= radius from
n
.- lengthstr, default mm_len
The name of the attribute of segment length (geographical).
- distancestr, optional
Use specified edge data key as distance. For example, setting
distance=’weight’
will use the edgeweight
to measure the distance from the noden
duringego_graph
generation.- verbosebool (default True)
If
True
, shows progress bars in loops and indication of steps.
- Returns:
- netxGraph
A networkx.Graph object.
Examples
>>> network_graph = mm.node_density(network_graph, radius: int=5)