momepy.building_adjacency#
- momepy.building_adjacency(contiguity_graph, neighborhood_graph)[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 captured by
contiguity_graph
and buildings within the neighborhood defined inneighborhood_graph
.Adapted from [Vanderhaegen and Canters, 2017].
- Parameters:
- contiguity_graphlibpysal.graph.Graph
Graph representing contiguity between geometries, typically a rook contiguity graph derived from buildings.
- neighborhood_graphlibpysal.graph.Graph
Graph representing the extent around each geometry within which to calculate the level of building adjacency. This can be a distance based graph, KNN graph, higher order contiguity, etc.
- Returns:
- Series
Notes
Both graphs must be built on the same index.
Examples
>>> from libpysal import graph >>> path = momepy.datasets.get_path("bubenec") >>> buildings = geopandas.read_file(path, layer="buildings")
Define a spatial graph denoting building contiguity:
>>> contig = graph.Graph.build_contiguity(buildings) >>> contig <Graph of 144 nodes and 248 nonzero edges indexed by [0, 1, 2, 3, 4, ...]>
Define a spatial graph denoting the neighborhood:
>>> knn15 = graph.Graph.build_knn(buildings.centroid, k=15) >>> knn15 <Graph of 144 nodes and 2160 nonzero edges indexed by [0, 1, 2, 3, 4, ...]>
Measure mean interbuilding distance:
>>> momepy.building_adjacency(contig, knn15) 0 0.6875 1 0.1875 2 0.1875 3 0.2500 4 0.1875 ... 139 0.4375 140 0.1875 141 0.1875 142 0.1875 143 0.2500 Name: building_adjacency, Length: 144, dtype: float64