I'm trying to query Hotels in a specific area. Unfortunately I need to query nodes and ways, because some Hotels are only stored as way and some as nodes.
http://overpass.osm.rambler.ru/cgi/interpreter?data=%28way[tourism~hotel]%28around:5000,50.10707,8.76040%29%29;out;
The result of a way-query doesn't contain any coordinates, only lots of node-refs:
<nd ref="1438833423"/>
Is there a way also to include the coordinates of the nodes in the output or do have to start lots of additional queries for each node?
Tom
Yes, there are several ways to also get geometries for non-node features via the Overpass API. The easiest is probably to use the center
output mode (replace out;
with out center;
): http://overpass-turbo.eu/s/4O4. Other options would be to fetch the node references in a recursion step: http://overpass-turbo.eu/s/4O5 or using the full geometry output mode.
PS: Don't forget that a hotel can also be mapped as a (multipolygon) relation in OSM, not just as a node or way.
Necromancing.
And to actually answer the question:
[out:json];
way(29858799);
out ids geom;
Which will give you the geometries for each point in the selected way.
{
"version": 0.6,
"generator": "Overpass API",
"osm3s": {
"timestamp_osm_base": "2017-10-06T13:59:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "way",
"id": 29858799,
"bounds": {
"minlat": 47.3604067,
"minlon": 8.5342631,
"maxlat": 47.3612503,
"maxlon": 8.5352457
},
"geometry": [
{ "lat": 47.3612503, "lon": 8.5351944 },
{ "lat": 47.3612252, "lon": 8.5342631 },
{ "lat": 47.3610145, "lon": 8.5342755 },
{ "lat": 47.3610212, "lon": 8.5345227 },
{ "lat": 47.3606405, "lon": 8.5345451 },
{ "lat": 47.3606350, "lon": 8.5343411 },
{ "lat": 47.3604067, "lon": 8.5343545 },
{ "lat": 47.3604120, "lon": 8.5345623 },
{ "lat": 47.3604308, "lon": 8.5352457 },
{ "lat": 47.3606508, "lon": 8.5352328 },
{ "lat": 47.3606413, "lon": 8.5348784 },
{ "lat": 47.3610383, "lon": 8.5348551 },
{ "lat": 47.3610477, "lon": 8.5352063 },
{ "lat": 47.3612503, "lon": 8.5351944 }
]
}
]
}
https://overpass-turbo.eu/
All the options for out are listed here:
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Print_.28out.29
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With