momepy.NeighborDistance

class momepy.NeighborDistance(gdf, spatial_weights, unique_id)[source]

Calculate the mean distance to adjacent buildings (based on spatial_weights)

If no neighbours are found, return np.nan.

\[\frac{1}{n}\sum_{i=1}^n dist_i=\frac{dist_1+dist_2+\cdots+dist_n}{n}\]
Parameters:
gdf : GeoDataFrame

GeoDataFrame containing objects to analyse

spatial_weights : libpysal.weights

spatial weights matrix based on unique_id

unique_id : str

name of the column with unique id used as spatial_weights index.

References

Schirmer PM and Axhausen KW (2015) A multiscale classification of urban morphology. Journal of Transport and Land Use 9(1): 101–130. (adapted)

Examples

>>> buildings_df['neighbour_distance'] = momepy.NeighborDistance(buildings_df, sw, 'uID').series
100%|██████████| 144/144 [00:00<00:00, 345.78it/s]
>>> buildings_df['neighbour_distance'][0]
29.18589019096464
Attributes:
series : Series

Series containing resulting values

gdf : GeoDataFrame

original GeoDataFrame

sw : libpysal.weights

spatial weights matrix

id : Series

Series containing used unique ID

__init__(self, gdf, spatial_weights, unique_id)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, gdf, spatial_weights, unique_id) Initialize self.