momepy.
Neighbors
(gdf, spatial_weights, unique_id, weighted=False)[source]¶Calculate the number of neighbours captured by spatial_weights
If weighted=True, number of neighbours will be divided by the perimeter of object to return relative value.
GeoDataFrame containing objects to analyse
spatial weights matrix
name of the column with unique id used as spatial_weights index
if weighted=True, number of neighbours will be divided by the perimeter of object, to return relative value
References
Hermosilla T, Ruiz LA, Recio JA, et al. (2012) Assessing contextual descriptive features for plot-based classification of urban areas. Landscape and Urban Planning, Elsevier B.V. 106(1): 124–137.
Examples
>>> sw = libpysal.weights.contiguity.Queen.from_dataframe(tessellation_df, ids='uID')
>>> tessellation_df['neighbours'] = momepy.Neighbors(tessellation_df, sw, 'uID').series
100%|██████████| 144/144 [00:00<00:00, 6909.50it/s]
>>> tessellation_df['neighbours'][0]
4
Series containing resulting values
original GeoDataFrame
Series containing used values
spatial weights matrix
Series containing used unique ID
used weighted value
__init__
(self, gdf, spatial_weights, unique_id, weighted=False)[source]¶Initialize self. See help(type(self)) for accurate signature.
Methods
|
Initialize self. |