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

Overpass turbo bbox - reducing amount of data for a relation with many ways

3
1

I am trying to query on hiking routes http://overpass-turbo.eu/s/q52 using the following centred on London.

[out:json][timeout:25];
relation["route"="hiking"]({{bbox}});
out geom;

I am finding I getting data I don't want which has a performance impact. I think I have two issues.

  1. Some of the relations are very big. (3212473 Greenwich Meridian Trail 20469 Thames Path)
  2. I am getting relations that are way outside my viewport (Shakespeare's Way - 71448) and I can't see why.

On point 1., can I process the relation - eg only output the ways that appears in my viewport. If I am interested in London I dont want details of the route near lincoln.

asked 30 Jun '17, 09:53

andrewblack's gravatar image

andrewblack
3651214
accept rate: 57%

edited 30 Jun '17, 10:25

Re Shakespeare's Way - something odd about the data. Investigating further

(30 Jun '17, 12:43) andrewblack

I have an answer to this. Will write up tomorrow

(30 Jun '17, 23:42) andrewblack

One Answer:

4

If you want all relations being tagged with route=hiking but only those ways of those relations which are inside your bounding box, you should try following query:

[out:json][timeout:25];
// Store all interesting relations which intersect with the bounding box in
// a set called "interestingrelations".
relation["route"="hiking"]({{bbox}})->.interestingrelations;
// Store all way members of the relations in the set "interestingrelations"
// in the set "alltheirways".
way(r.interestingrelations)->.alltheirways;
// Filter "alltheirways" using a bounding box filter. Store result in "waysinside".
way.alltheirways({{bbox}})->.waysinside;
// Output geometry of "waysinside".
.waysinside out geom;

Features of Overpass QL in use:

answered 10 Jul '17, 19:47

Nakaner's gravatar image

Nakaner
610813
accept rate: 16%

1

Wow, that is a life saver! Here's how I finally got just the slice of the border of Paraguay that I needed:

relation(389884)->.interestingrelations;

way(r.interestingrelations)->.alltheirways;

way.alltheirways(-25.2,-59.5,-24.2,-58)->.waysinside;

.waysinside out geom;

(12 Oct '20, 08:29) jidanni
1

FYI: http://overpass-turbo.eu/s/Z1J relation(389884); way(r)(-25.2,-59.5,-24.2,-58); out geom;

(14 Oct '20, 19:49) DaveF

Source code available on GitHub .