Python Forum

Full Version: how to retrieve datas with Overpass API python wrapper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello dear community

new to this community,

currently want to dive into Python with some real world projects + connecting to the endpoint of Overpass.
with the overpass-api-python wrapper i want to do the first steps today:

well this example code here:

import overpass
api = overpass.API()
response = api.Get('node["name"="Salt Lake City"]')
should give with this command:


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)]
a list of comma seperated values - is this correct.... ? i want to translate the following overopass-turbo request into the overpass-api-python wrapper.


[out:csv(::id,::type,"name","addr:postcode","addr:city","addr:street","addr:housenumber","website"," contact:email=*")][timeout:600];
{{geocodeArea:Schweiz}}->.a;
( node(area.a)[amenity=hospital];
  way(area.a)[amenity=hospital];
  rel(area.a)[amenity=hospital];);
out;
my approach;

The API object takes a few parameters:

endpoint

api = overpass.API(timeout=600)

but what with the query:

[out:csv(::id,::type,"name","addr:postcode","addr:city","addr:street","addr:housenumber","website"," contact:email=*")][timeout:600];
{{geocodeArea:Schweiz}}->.a;
( node(area.a)[amenity=hospital];
  way(area.a)[amenity=hospital];
  rel(area.a)[amenity=hospital];);
out;
HOW TO translate this into the python wrapper-request.