This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to put a query in a single line to invoke from a script?

0

Hi, I made a query that does what I want, http://overpass-turbo.eu/s/e97 but I found no info on how to put in a single to invoke from a script like wget <query>. Any help is welcomed.

asked 02 Feb '16, 19:51

davide_ttk's gravatar image

davide_ttk
21112
accept rate: 0%

edited 02 Feb '16, 20:57

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


3 Answers:

4
  • In overpass turbo run your query.
  • Click on export button and choose raw data from overpass api.
  • Use the url of the page you landed on for wget.

answered 02 Feb '16, 20:34

RM87's gravatar image

RM87
3.3k23753
accept rate: 22%

1

You can try to use Overpass API

wiki page: [1]: https://wiki.openstreetmap.org/wiki/Overpass_API

site page: http://overpass-api.de/

and for a page that explain how to use it from a command line (or in your case from a script) see this page: http://overpass-api.de/command_line.html

Please note this two point:

1) the main server has an usage policy (see the wiki page about that)

2) the syntax used by Overpass api may be different from the one used by Overpass Turbo (I am not sure about this, there are two many languages used, I get confused)

answered 02 Feb '16, 20:41

AnyFile's gravatar image

AnyFile
403
accept rate: 0%

Thanks AnyFile it was exactly what I needed

(02 Feb '16, 22:20) davide_ttk

0

Remove comments and newlines. You should get something like this:

[out:json][timeout:25];(node (poly: "45.5 11 45.6 11.6 45.2 11")["natural"="peak"];);out body;>;out skel qt;

urlencode that string. You can use this http://meyerweb.com/eric/tools/dencoder/ or any other tool for urlencode.

Get the encoded string and slap it in wget:

wget -O result.json "http://overpass.osm.rambler.ru/cgi/interpreter?data=%5Bout%3Ajson%5D%5Btimeout%3A25%5D%3B(node%20(poly%3A%20%2245.5%2011%2045.6%2011.6%2045.2%2011%22)%5B%22natural%22%3D%22peak%22%5D%3B)%3Bout%20body%3B%3E%3Bout%20skel%20qt%3B"

answered 03 Feb '16, 07:09

ivanatora's gravatar image

ivanatora
2.7k355568
accept rate: 7%

Source code available on GitHub .