Overpass API return different results between Overpass Turbo export and wget

openstreetmapoverpass-apioverpass-turbo

I need to get from OSM all all nodes in the bounding box, all ways referring to any of these nodes, all member nodes of these ways whether these are inside the bounding box or not, all relations that have such a node or such a way as a member, and their node and way member, and even the nodes of these ways.

According to:
https://wiki.openstreetmap.org/wiki/Overpass_API/Advanced_examples
I use this query:

(
node(45.54,9.19,45.55,9.2);
 <;
 >;
);
out meta;

From the browser, using overpass turbo, I call url:

http://overpass-turbo.eu/?Q=(%0A%20%20node(45.54%2C9.19%2C45.55%2C9.2)%3B%0A%20%20%3C%3B%0A%20%20%3E%3B%0A)%3B%0Aout%20meta%3B%0A%0A%0A&C=45.53691;9.1995;15

and get a complete 84.2 MB .osm file

If I use wget according to http://overpass-api.de/command_line.html:

wget -O target.osm "https://overpass-api.de/api/interpreter?data=node(45.54,9.19,45.55,9.2);<;>;out meta;

I get a 79.9 MB .osm incomplete file, without some ways in the box.
Why the 2 results are different?

Best Answer

It seems you forgot to include the union statement (the two round brackets) in your second example. They're necessary to include nodes, ways, and all nodes referred to by ways in your response. If you leave them out, you will only receive an incomplete answer.

(           // <<<<<<< start of union statement
node(45.54,9.19,45.55,9.2);
 <;
 >;
);          // <<<<<<< end of union statement
out meta;

To avoid this mistake in the future, you can enter your query in overpass turbo, then hit "Export" -> "raw data directly from Overpass API". This will create a download link suitable for wget right away.

Related Question