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

[overpass] Get all ways which aren’t part of a specific relation

0

I'm trying to write an Overpass query to get all ways (filtered with a specific tag) which aren't included in a relation (with a specific tag).

Here is my query (edited after maxerickson's answer): https://overpass-turbo.eu/s/HXj

// Collect all ways with piste:type=nordic and store the result in a variable .all
way({{bbox}})["piste:type"="nordic"]->.all;

// Select all relations, where one of the ways in variable .all is a member
rel["piste:type"="nordic"](bw.all);
// ...and for those relations find all related way members
way(r);

// Calculate the set difference (._ contains all nodes which are member of a relation)
( .all; - ._; );

// return the result including meta data
out meta;

I followed this example, it's pretty close of what I want to do but for nodes, so I just changed a few things to get ways instead of nodes.

Unfortunately my query doesn't return anything. Do you see anything wrong in my query?

Edit after some debugging:

here a way that the query should return (has a piste:typenordic tag and isn't part of a piste:type=nordic relation): https://www.openstreetmap.org/way/475719899

  • the way is returned if I tell Overpass to display the .all set: https://overpass-turbo.eu/s/HXh → good
  • the way isn't returned when I search for all way that are part of a relation (lines 5-7): https://overpass-turbo.eu/s/HXi → good
  • so I guess the problem is on the difference between the 2 sets (line 10): why the way 475719899 is removed if it isn't in the ._ set?

Thanks!

asked 12 Apr '19, 14:17

billux's gravatar image

billux
11113
accept rate: 0%

edited 13 Apr '19, 13:46


One Answer:

1

You need something like

area[name="Sainte-Adèle"]->.searchArea;
way(area.searchArea)["piste:type"="nordic"]->.all;

to even have anything in .all.

The area query operates on OSM tags, so you have to search based on that. You could use around with a distance and a point (either an OSM node or directly specify lat/lon) if that better matches your intent.

answered 13 Apr '19, 03:28

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

You're right, actually I wanted to use {{bbox}} first, but replaced it with area when I posted my question. I have updated my question with a link to the Overpass query and more information after trying to debug the query.

(13 Apr '19, 13:53) billux
2

I'm not sure why, but naming the second result set helps: https://overpass-turbo.eu/s/HXB

(13 Apr '19, 17:34) maxerickson

That's strange, I don't understand why ._ can't be used in that case. Anyway the query works as expected now. Thanks!

(14 Apr '19, 22:23) billux

The .all in the difference statement has ._ as result set. The next statment ._ picks that up. Thus, you are subtracting the content of .all from itself. I'm sorry that the syntax is misleading in this case.

(26 Apr '19, 18:52) Roland Olbricht

Source code available on GitHub .