Administrative boundary regionalizer
Administrative Boundary Regionalizer.
This module contains administrative boundary regionalizer implementation.
AdministrativeBoundaryRegionalizer(
admin_level,
clip_regions=True,
return_empty_region=False,
prioritize_english_name=True,
toposimplify=True,
remove_artefact_regions=True,
)
¶
AdministrativeBoundaryRegionalizer(
admin_level,
clip_regions=True,
return_empty_region=False,
prioritize_english_name=True,
toposimplify=True,
remove_artefact_regions=True,
)
Bases: Regionalizer
AdministrativeBoundaryRegionalizer.
Administrative boundary regionalizer allows the given geometries to be divided
into boundaries from OpenStreetMap on a given admin_level
[1].
Downloads those boundaries online using overpass
and osmnx
libraries.
Note: offline .pbf loading will be implemented in the future. Note: option to download historic data will be implemented in the future.
PARAMETER | DESCRIPTION |
---|---|
admin_level |
OpenStreetMap admin_level value. See [1] for detailed description of available values.
TYPE:
|
clip_regions |
Whether to clip regions using a provided mask. Turning it off can an be useful when trying to load regions using list a of points. Defaults to True.
TYPE:
|
return_empty_region |
Whether to return an empty region to fill remaining space or not. Defaults to False.
TYPE:
|
prioritize_english_name |
Whether to use english area name if available as a region id first. Defaults to True.
TYPE:
|
toposimplify |
Whether to simplify topology to reduce
geometries size or not. Value is passed to
TYPE:
|
remove_artefact_regions |
Whether to remove small regions barely intersecting queried area. Turning it off can sometimes load unnecessary boundaries that touch on the edge. It removes regions that intersect with an area smaller than 1% of total self. Takes into consideration if provided query GeoDataFrame contains points and then skips calculating area when intersects any point. Defaults to True.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If admin_level is outside available range (1-11). See [2] for list of
values with |
References
Source code in srai/regionalizers/administrative_boundary_regionalizer.py
¶
Regionalize a given GeoDataFrame.
Will query Overpass [1] server using overpass
[2] library for closed administrative
boundaries on a given admin_level and then download geometries for each relation using
osmnx
[3] library.
If prioritize_english_name
is set to True
, method will try to extract the name:en
tag
first before resorting to the name
tag. If boundary doesn't have a name
tag, an id
will be used.
Before returning downloaded regions, a topology is built and can be simplified to reduce
size of geometries while keeping neighbouring regions together without introducing gaps.
Topojson
library [4] is used for this operation.
Additionally, an empty region with name EMPTY
can be introduced if returned regions do
not fully cover a clipping mask.
PARAMETER | DESCRIPTION |
---|---|
gdf |
GeoDataFrame to be regionalized. Will use this list of geometries to crop resulting regions.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame with the regionalized data cropped using input GeoDataFrame. |
RAISES | DESCRIPTION |
---|---|
RuntimeError
|
If simplification can't preserve a topology. |
References
Source code in srai/regionalizers/administrative_boundary_regionalizer.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|