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

Wondering how to write an Overpass query to find ways in cycle route relations that have surface=paved tagged on the way. Here's my best effort, which is doing fine getting ways within cycle relations, but is not filtering for ways tagged surface=paved:

[out:json][timeout:90];
(
(rel["route"="bicycle"]({{bbox}});)->.cr;
(.cr>;)->.w;
(way.w["surface"="paved"];)->.sp;
);
.sp out body;
>;
out skel qt;

Note: this question came up on GIS StackExchange

asked 17 Jun '15, 15:32

neuhausr's gravatar image

neuhausr
7.5k870121
accept rate: 21%


I suggest http://overpass-turbo.eu/s/9Zf instead.

Let's also do a walk-through of the above query:

The parentheses opening in line 2 and closing in line 6 mean that the input of line 8

>;

are the union of the results in lines 3, 4, and 5. In particular, in line 3 we collect all the relations with "route"="bicycle". Thus, the recurse-down collects all the ways that are members of these relations. In line 9, these resulting ways, along also found nodes from these ways, are printed.

To avoid this, you need to remove the parentheses in line 2 and 6. Fruthermore, the parentheses in lines 3, 4, and 5 also have no effect, because there is in each case only a single query inside.

The remaining differences are that I have simplified the different set names to always the default set name. Because some relations may have an enormous extent, I have also added a "({{bbox}})" condition to the "way" query to restrict the results to the given bbox. It would work without, but admittedly slower. To speed up without bounding box, you can use

[out:json][timeout:90];
rel["route"="bicycle"]({{bbox}});
way(r);
way._["surface"="paved"];
out geom;

This splits the way query into two steps to enforce that the filtering for relation members is applied first.

Please feel free to paste back the content to GIS StackExchange. I consider my answers here as CC0.

permanent link

answered 17 Jun '15, 17:05

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

1

Thanks so much, especially for the walk-through pointing out where I went wrong!

(18 Jun '15, 14:39) neuhausr
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
×167
×147

question asked: 17 Jun '15, 15:32

question was seen: 6,730 times

last updated: 18 Jun '15, 14:39

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