Skip to content

Instantly share code, notes, and snippets.

@rodericj
Created January 18, 2021 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodericj/44774747a2470b05d1b2a97d268672f7 to your computer and use it in GitHub Desktop.
Save rodericj/44774747a2470b05d1b2a97d268672f7 to your computer and use it in GitHub Desktop.
Fetch GeoJson Region for Crozes Hermitage using Nominatim and Overpass using Python
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