Geocode
Utility function for geocoding a name to regions_gdf
.
¶
Geocode a query to the regions_gdf
unified format.
This functions is a wrapper around the ox.geocode_to_gdf
[1] function from the osmnx
library.
For parameters description look into the source documentation.
PARAMETER | DESCRIPTION |
---|---|
query |
Query string(s) or structured dict(s) to geocode.
TYPE:
|
by_osmid |
Flag to treat query as an OSM ID lookup rather than text search. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame with geocoded regions. |
Examples:
Download geometry for a city
>>> from srai.regionalizers import geocode_to_region_gdf
>>> geocode_to_region_gdf("Wrocław, PL")
geometry
region_id
Wrocław, Lower Silesian Voivodeship, Poland POLYGON ((...
Download geometries for multiple cities
>>> geocode_to_region_gdf(["New York City", "Washington, DC"])
geometry
region_id
New York, United States MULTIPOLYGON (((...
Washington, District of Columbia, United States POLYGON ((...
Use OSM relation IDs to get geometries.
>>> geocode_to_region_gdf(["R175342", "R5750005"], by_osmid=True)
geometry
region_id
Greater London, England, United Kingdom POLYGON ((...
Sydney, Council of the City of Sydney, New Sout... POLYGON ((...