hello dear community, good evening dear Python-experts




- since this is a real python-question i think you might be able to help me.


we have with Overpass API python wrapper a thin Python wrapper around the OpenStreetMap Overpass API https://github.com/mvexel/overpass-api-python-wrapper

we have some Simple example:

import overpass
api = overpass.API()
response = api.Get('node["name"="Salt Lake City"]')

Note that we don't have to include any of the output meta statements. The wrapper will, well, wrap those.
we will get our result as a dictionary, which represents the JSON output you would get from the Overpass API directly.

print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637), (u'Salt Lake City', 1615721573)]

we an specify the format of the response. By default, we will get GeoJSON using the responseformat parameter.
Alternatives are plain JSON (json) and OSM XML (xml), as ouput directly by the Overpass API.

response = api.Get('node["name"="Salt Lake City"]', responseformat="xml")

question: can we also get cvs - can we perform a request like below with the python wrapper to the endpoint of overpass turbo?

[out:csv(::id,::type,"name","addrostcode","addr:city",
"addr:street","addr:housenumber","website"," contact:email=*")][timeout:30];
area[name="Madrid"]->.a;
( node(area.a)[amenity=hospital];
way(area.a)[amenity=hospital];
rel(area.a)[amenity=hospital];
out;

well - how to use the above metioned overpass-turbo-request at the endpoint of the overpass-api?


The wrapper returns a dictionary, so if we want something like the CSV output we are looking for, we need to create that from the dictionary that the request outputs.

btw: {{geocodeArea:*}} is not a native Overpass syntax, we should use an area ID.

The request we could feed into the Get method would be something along the lines of:

area(3601744366)->.a;
(node(area.a)[amenity=hospital];
way(area.a)[amenity=hospital];
(._;>;