I try to get the geocodes coordinates from the location(nominatim) into the Overpass query.

Is there an easy way to do this?

import json
import requests
from geopy.geocoders import Nominatim

geolocator = Nominatim(user_agent="your_app_name")
location = geolocator.geocode("Hufnerstraße 1, Hamburg")

lat = location.latitude
lng = location.longitude

print(lat, lng)

overpass_url = "http://overpass-api.de/api/interpreter"

overpass_query = """

response = requests.get(overpass_url, params={'data': overpass_query})
data = response.json()


1 Answer 1


Since the overpass_query is just a string, you can use string formatting:

overpass_query = f"""

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.