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

// Select all relations, where one of the ways in variable .all is a member
// ...and for those relations find all related way members

// 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?


asked 12 Apr '19, 14:17

billux's gravatar image

accept rate: 0%

edited 13 Apr '19, 13:46

You need something like


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.

permanent link

answered 13 Apr '19, 03:28

maxerickson's gravatar image

accept rate: 30%

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

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
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Apr '19, 14:17

question was seen: 660 times

last updated: 26 Apr '19, 18:52

powered by OSQA