momepy.NeighborDistance#

class momepy.NeighborDistance(gdf, spatial_weights, unique_id, verbose=True)[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}\]

Adapted from [Schirmer and Axhausen, 2015].

Parameters:
gdfGeoDataFrame

A GeoDataFrame containing objects to analyse.

spatial_weightslibpysal.weights

A spatial weights matrix based on unique_id.

unique_idstr

The name of the unique ID column used as the spatial_weights index.

verbosebool (default True)

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

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:
seriesSeries

A Series containing resulting values.

gdfGeoDataFrame

The original GeoDataFrame.

swlibpysal.weights

The spatial weights matrix.

idSeries

A Series containing used unique ID.

__init__(gdf, spatial_weights, unique_id, verbose=True)[source]#

Methods

__init__(gdf, spatial_weights, unique_id[, ...])