NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I want to use overpass to get all relations in a specific relation. I know there will be at least three levels: relation A holds relation B which holds relation C. But when I use the relation recurse in overpass twice, I do not get relation B, I only get the relations that do not hold any relations in them.
My query is:

relation
  ["name"="Twente"]
  ["network"="public_transport"];
rel(r);
rel(r);
out;

Without recurse, the relation that gets returned is 360309. With one recurse I get all the relations in it, e.g. 5617486 which is a relation that holds two relations. With two recurses, I get the relations that are held by 5617486, but I do not get 5617486 anymore.
Is there a way to get also relation 5617486 (and similar "intermediate" relations)?

asked 28 Oct '15, 10:12

Maarten%20Deen's gravatar image

Maarten Deen
26113
accept rate: 0%


out; will only return the current inputset, in this case the result of the last rel(r);. If you want the result of both rel(r); you need to put both statements inside a union block:

relation
  ["name"="Twente"]
  ["network"="public_transport"];
( rel(r); rel(r); );
out;

Maybe you should also take a look at recurse down relations (or for short: >>; ). This avoids manual resolution of nested relations, like you did in your example. Please refer to the wiki for details.

Another option would the complete statement, which is currently only available on the test instance: it can be leveraged to automatically resolve the nested relation only (ignoring and ways/nodes contained in the relation). Here's a link to the preview version: http://overpass-turbo.eu/s/cmw (returns 102 relations, which are only visible in overpass turbo's data tab).

permanent link

answered 28 Oct '15, 14:47

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

edited 29 Oct '15, 18:17

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×483
×236
×3

question asked: 28 Oct '15, 10:12

question was seen: 2,773 times

last updated: 29 Oct '15, 18:17

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum