Jump to content

overpass-request via command-line - how to performe


Maze

Recommended Posts

hi dear community

 

 

have to perform some big requests to the overpass-api -

 

i want to do this via commandline. cf  http://overpass-api.de/command_line.html
 

note: if i do it with the overpass-turbo.eu - api all runs well.


[out:csv(::id,::type,"name","website"," contact:email=*")];
area[name="Heidelberg"]->.a;
( node(area.a)[amenity=hospital];
  way(area.a)[amenity=hospital];
  rel(area.a)[amenity=hospital];
out;

output:
 

@id    @type    name    website     contact:email=*
145970634    node            
303300521    node    Thoraxklinik    http://www.thoraxklinik-heidelberg.de    
678470357    node    Kurpfalzkrankenhaus    http://www.srh.de/de/kk-heidelberg/index.html    
1279003446    node    Mercy Hospital for Women    www.mercyhealth.com.au    
1732872588    node    GRN-Klinik Weinheim    www.grn.de/klinik-weinheim    
2343179537    node    Klinik für Allgemeine Innere Medizin und Psychosomatik    http://www.klinikum.uni-heidelberg.de/Klinik-fuer-Allgemeine-Innere-Medizin-und-Psychosomatik.1088.0.html    
3217716361    node    kopfklinik        
24595717    way    Austin Hospital    http://www.austin.org.au/    
25208382    way    Blutspendezentrale Heidelberg IKTZ        
49501406    way    Klinik für Kinder- und Jugendpsychiatrie - Tageszentrum für Jugendliche    http://www.klinikum.uni-heidelberg.de/Tageszentrum-fuer-Jugendliche.118360.0.html    
90355808    way    Kliniken Schmieder Heidelberg    http://www.kliniken-schmieder.de    
91097339    way    Salem    http://www.krankenhaus-salem.de    
96690377    way    Unfallchirurgie - Atos    http://www.atos.de/klinik/    
99998610    way    Warringal Private    www.warringalprivate.com.au    
140128817    way    Institut für Psychosomatische Kooperationsforschung und Familientherapie    http://www.klinikum.uni-heidelberg.de/ZPM-Startseite.106894.0.html    
141216666    way    Tropenmedizinische Ambulanz    http://www.klinikum.uni-heidelberg.de/Sektion-Klinische-Tropenmedizin.5489.0.html    

 

 

 

and so forth        

well according this document http://overpass-api.de/command_line.html

 

i can do a commandline - request:

For short queries, the usage is very simple: Just write the query in the command line:

wget "http://overpass-api.de/api/interpreter?data=node[name=\"Gielgen\"];out;"

Please note that we need to escape the quotation mark ("). Because we have enclosed the URL in quotation marks, we must escape only two more characters: the dollar ($) sign should get (\$) and the backslash (\) should be doubled (\\).

In most cases it would be helpful to store the results with a meaningful filename. Use -O for that purpose:

wget -O target.osm "http://overpass-api.de/api/interpreter?data=node[name=\"Gielgen\"];out;"

For longer queries, it could be helpful to have the query in a separate file. That is also possible:

echo "data=node[name=\"Gielgen\"];out;" >query.osm
wget -O target.osm --post-file=query.osm "http://overpass-api.de/api/interpreter"

end of cit.

 

how do i do the command -....

 

 

should i do it like so;

 

wget -O target.osm "http://overpass-api.de/api/interpreter?data=node[name=\"Gielgen\"];out;"

[out:csv(::id,::type,"name","website"," contact:email=*")];
area[name=Heidelberg]->.a;
( node(area.a)[amenity=hospital];
  way(area.a)[amenity=hospital];
  rel(area.a)[amenity=hospital];);
out;

 

love to hear from you

Link to comment
Share on other sites

  • 7 years later...

I had a similar problem, but I could figured out somehow.

In my project I want to get switches around in 1 km of one specific railway stations, in overpass-turbo I run this: node[uic_ref="5516147"]->.allomas;node(around.allomas:1000)[railway~"(switch|railway_crossing)"];out;

So with php I get data in xml like this:

$xml = simplexml_load_string(file_get_contents('https://overpass-api.de/api/interpreter?data=node[uic_ref="'.$uic_ref.'"]->.allomas;node(around.allomas:1000)[railway~"(switch|railway_crossing)"];out;'));

After that I could parse the xml. In my opinion xml is more expedient than csv.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.