AdjacencyNeighbourhood
¶
Bases: Neighbourhood[Hashable]
Adjacency Neighbourhood.
This class allows to get the neighbours of any region based on common border. Additionally, a lookup table is implemented to accelerate repeated queries.
By default, a lookup table will be populated lazily based on queries. A dedicated function
generate_neighbourhoods
allows for precalculation of all the neighbourhoods at once.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf |
regions for which a neighbourhood will be calculated.
TYPE:
|
include_center |
Whether to include the region itself in the neighbours.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If regions_gdf doesn't have geometry column. |
Source code in srai/neighbourhoods/adjacency_neighbourhood.py
¶
Generate the lookup table for all regions.
Source code in srai/neighbourhoods/adjacency_neighbourhood.py
¶
Get the direct neighbours of any region using its index.
PARAMETER | DESCRIPTION |
---|---|
index |
Unique identifier of the region.
TYPE:
|
include_center |
Whether to include the region itself in the neighbours.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
set[Hashable]
|
Set[Hashable]: Indexes of the neighbours. |
Source code in srai/neighbourhoods/adjacency_neighbourhood.py
¶
Get the neighbours of a region up to a certain distance.
PARAMETER | DESCRIPTION |
---|---|
index |
Unique identifier of the region. Dependant on the implementation.
TYPE:
|
distance |
Maximum distance to the neighbours.
TYPE:
|
include_center |
Whether to include the region itself in the neighbours.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
set[IndexType]
|
Set[IndexType]: Indexes of the neighbours. |
Source code in srai/neighbourhoods/_base.py
¶
Get the neighbours of a region at a certain distance.
PARAMETER | DESCRIPTION |
---|---|
index |
Unique identifier of the region. Dependant on the implementation.
TYPE:
|
distance |
Distance to the neighbours.
TYPE:
|
include_center |
Whether to include the region itself in the neighbours.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
set[IndexType]
|
Set[IndexType]: Indexes of the neighbours. |