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

Query all roads within AND those exactly on the boundary of an area with overpass

0

I am trying to download all roads for a specific area rel:2800276, including those exactly on the boundary of the area (e.g. way:171480859). However, the query seems slow if I add a few commands (Line 3-4) specifically ask for proximity to the boundary of area like this:

[out:json][timeout:3600][maxsize:1073741824];
area(3602800276)->.t;
rel(pivot.area.t);
way["highway"](around:0.0);
(._;way["highway"](area.t););
(._;>;);
out;

Should I use some other methods to include the roads exactly on the boundary? It looks like by default the area filter just report features with at least one point properly within the area.

** For simplicity, all ways with highway tag are assumed to be roads here.

asked 07 Oct '22, 07:58

yikhim's gravatar image

yikhim
11112
accept rate: 0%


One Answer:

0

I hope I'm proved incorrect, but I don't think there's a simple way to perform this. To me the is_in command should be able to perform this.

First, the reason your routine is slow is way["highway"](around:0.0); is searching the whole globe for all for highway. It needs to be passed the desired area to search. Your next line is superfluous as it's duplicating the previous.

This routine: The first 'out' is, hopefully, all ways touching the relati9on. Second is all ways within the relation. Third is the relation itself.

rel(2800276)->.Kwun;
way(around.Kwun:0)[highway=secondary];
out geom;

.Kwun;map_to_area;
way(area)[highway=secondary];
out geom;

.Kwun out geom;

General Point: you may want to check if the boundary does actually go down the centreline of the road. They rarely do.

answered 07 Oct '22, 18:55

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 07 Oct '22, 19:08

Source code available on GitHub .