Is there a way to select a relation with all of its members belonging to a specific area? I'm currently working with hiking routes and I want to store all the hiking tracks for a given input area. As far as I understand from the docs, even if a relation has only one member in the selected area it will be included. Is there any simple workaround to avoid that? Here is a basic example, any suggestion would be much appreciated. I'm quite new to OSM and OverpassQL, sorry in advance if this is elementary stuff. asked 01 Jun '21, 01:13 Debo790 |
One approach is to use I didn't look at the output to see if it was entirely correct, but it at least goes in the right direction. I'm not sure if it would work to use the relation as one of the inputs (using the member ways ensures that only intersections with the boundary are considered; it may work the same with the relation as the input). answered 01 Jun '21, 22:57 maxerickson This seems to work fine, it becomes quite heavy scaling the boundaries up to provinces but keeping admin_level=8 results are good even in terms of time. I've perfomed some tests with cities full of hiking routes and also with cities that shows no routes at all, results seems correct in both cases. Thanks a lot!
(02 Jun '21, 01:09)
Debo790
|
answered 04 Jun '21, 21:32 DaveF This now retrieves the correct results, but it doesn't check for multiple cities (e.g. Milano or Roma). The code provided in the question (and in answer of maxerickson) deals with it using this: https://help.openstreetmap.org/questions/64305/overpass-api-get-city-boundaries-within-a-country-slow-query/70342 Obviously this decreases performances, but it's the best I came up with so far. Thanks for your effort anyway, your solution is the way to go when dealing with cities with no homonyms.
(05 Jun '21, 09:15)
Debo790
|
The nearest I've ever been able to trim to a boundary is to Recurse down to the way members & then search within the area, but this includes ways which overlap the boundary.
PS I wish OP had a global area option similar to bbox. It would save a lot of typing. answered 03 Jun '21, 16:56 DaveF This is actually faster, but it includes ways relations that shouldn't appear. An example is in the comment above the query: http://overpass-turbo.eu/s/185E The aim is to find relations with all the members inside the given area, if some of those members are outside then the whole relation should be discarded.
(04 Jun '21, 00:18)
Debo790
|
Just to make sure we understand each other: You want to extract all relations of which all members are inside a certain area. If any member is outside that area you want to exclude the whole relation. Is that the correct understanding?
Yes, correct. In the example provided the difference is minimal, but considering a larger area (e.g. a region, or a province) you may end up including routes that cover all the nation. This is an issue for me at the moment and I didn't find anything useful in other questions.