momepy.BuildingAdjacency#

class momepy.BuildingAdjacency(gdf, spatial_weights_higher, unique_id, spatial_weights=None, verbose=True)[source]#

Calculate the level of building adjacency. Building adjacency reflects how much buildings tend to join together into larger structures. It is calculated as a ratio of joined built-up structures and buildings within the extent defined in spatial_weights_higher.

Adapted from [Vanderhaegen and Canters, 2017].

Parameters:
gdfGeoDataFrame

A GeoDataFrame containing objects to analyse.

spatial_weights_higherlibpysal.weights

A spatial weights matrix.

unique_idstr

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

spatial_weightslibpysal.weights, optional

A spatial weights matrix. If None, a Queen contiguity matrix will be calculated based on gdf. It is to denote adjacent buildings and is based on unique_id.

verbosebool (default True)

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

Examples

>>> buildings_df['adjacency'] = momepy.BuildingAdjacency(buildings_df,
...                                                      swh,
...                                                      unique_id='uID').series
Calculating spatial weights...
Spatial weights ready...
Calculating adjacency: 100%|██████████| 144/144 [00:00<00:00, 335.55it/s]
>>> buildings_df['adjacency'][10]
0.23809523809523808
Attributes:
seriesSeries

A Series containing resulting values.

gdfGeoDataFrame

The original GeoDataFrame.

sw_higherlibpysal.weights

A higher order spatial weights matrix.

idSeries

A Series containing used unique IDs.

swlibpysal.weights

The spatial weights matrix.

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

Methods

__init__(gdf, spatial_weights_higher, unique_id)