momepy.
Neighbors
Calculate the number of neighbours captured by spatial_weights
spatial_weights
If weighted=True, number of neighbours will be divided by the perimeter of object to return relative value.
weighted=True
Adapted from [HRRCambraLopez12].
GeoDataFrame containing objects to analyse
spatial weights matrix
name of the column with unique id used as spatial_weights index
if True, number of neighbours will be divided by the perimeter of object, to return relative value
True
if True, shows progress bars in loops and indication of steps
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
Series containing used unique ID
used weighted value
__init__
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(gdf, spatial_weights, unique_id[, …])
Initialize self.