momepy.Neighbors#
- class momepy.Neighbors(gdf, spatial_weights, unique_id, weighted=False, verbose=True)[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.Adapted from [Hermosilla et al., 2012].
- Parameters
- gdfGeoDataFrame
GeoDataFrame containing objects to analyse
- spatial_weightslibpysal.weights
spatial weights matrix
- unique_idstr
name of the column with unique id used as
spatial_weights
index- weightedbool (default False)
if
True
, number of neighbours will be divided by the perimeter of object, to return relative value- verbosebool (default 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
- Attributes
- seriesSeries
Series containing resulting values
- gdfGeoDataFrame
original GeoDataFrame
- valuesSeries
Series containing used values
- swlibpysal.weights
spatial weights matrix
- idSeries
Series containing used unique ID
- weightedbool
used weighted value
Methods
__init__
(gdf, spatial_weights, unique_id[, ...])