momepy.DistanceBand#
- class momepy.DistanceBand(gdf, threshold, centroid=True, ids=None)[source]#
On demand distance-based spatial weights-like class.
Mimic the behavior of
libpysal.weights.DistanceBand
but do not compute all neighbors at once; only on demand. OnlyDistanceBand.neighbors[key]
is implemented. Once a user asks forDistanceBand.neighbors[key]
, neighbors for specified key will be computed usingrtree
. The algorithm is significantly slower thanlibpysal.weights.DistanceBand
but allows for a large number of neighbors which may cause memory issues in libpysal.Use
libpysal.weights.DistanceBand
if possible.momepy.weights.DistanceBand
only when necessary.DistanceBand.neighbors[key]
should yield the same results asmomepy.DistanceBand
.- Parameters:
- gdfGeoDataFrame or GeoSeries
The GeoDataFrame containing objects to be used.
- thresholdfloat
The distance band to be used as buffer.
- centroidbool (default True)
Use the centroid of geometries (as in
libpysal.weights.DistanceBand
). IfFalse
, this works with the geometry as it is.- idsstr
The column to be used as geometry IDs. If not set, integer position is used.
- Attributes:
- neighbors[key]list
A list of IDs of neighboring features.
Methods
fetch_items
Methods
__init__
(gdf, threshold[, centroid, ids])fetch_items
(key)