Created
January 18, 2021 04:06
-
-
Save rodericj/44774747a2470b05d1b2a97d268672f7 to your computer and use it in GitHub Desktop.
Fetch GeoJson Region for Crozes Hermitage using Nominatim and Overpass using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from OSMPythonTools.nominatim import Nominatim | |
from OSMPythonTools.overpass import overpassQueryBuilder, Overpass | |
# Create a Nominatim Query Object | |
crozesNominatimQuery = Nominatim().query('Crozes Hermitage') | |
# Create a query from the Nominatim Query object | |
query = overpassQueryBuilder(area=crozesNominatimQuery.areaId(), elementType=['way', 'relation'], includeGeometry=True) | |
# Or this: | |
query = overpassQueryBuilder(area=crozesNominatimQuery.areaId(), elementType=['way', 'relation'], selector='"boundary"="administrative"', includeGeometry=True) | |
#Perform the query: | |
result = Overpass().query(query) | |
#Then from the results print the geometry: | |
geoJson = result.elements()[0].geometry() | |
print(geoJson) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment