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

I can make an area in Overpass QL, using name and relation attributes (tags) filter of element, something like this:

area["name:en"="Moscow Oblast"]["boundary"="administrative"]["admin_level"="4"]->.region;
(node(area.region)[place="city"];node(area.region)[place="town"];);
out;

But searching via name is not so stable, and will broke if element name is changed. So much better (for performance too) is to make an area from element id. Here is example of searching relation via it's element id:

rel(51490);
out;

And can't understand, how to pass element type and id to area query? Something like this:

area(rel(51490))->.region;
(node(area.region)[place="city"];node(area.region)[place="town"];);
out;

or other variants like area["id"=51490]->.region; or area["type"="rel"]["rel"=51490])->.region; don't works.

Can anyone give me an example, how to make area from OSM element by it's id?

asked 09 Nov '20, 09:34

Murz's gravatar image

Murz
11112
accept rate: 0%


Other solution, provided from @mmd, is to use result of fist search via id of element as area, example:

rel(51490);map_to_area->.region;
node(area.region)[place="city"];
out;
permanent link

answered 09 Nov '20, 12:43

Murz's gravatar image

Murz
11112
accept rate: 0%

edited 09 Nov '20, 12:43

That's basically the same but with a conversion: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Map_way.2Frelation_to_area_.28map_to_area.29


btw where did @mmd post the reply?

(09 Nov '20, 13:01) DaveF

In Slack, because I ask similar question in Slack too, but before creating question here.

(09 Nov '20, 13:19) Murz

From the wiki:

By convention the area id can be calculated from an existing OSM way by adding 2400000000 to its OSM id, or in case of a relation by adding 3600000000 respectively.

https://overpass-turbo.eu/s/ZTF

area(3600051490);
node(area)[place~"^(city|town)$"];
out;

Multiple areas can be combined (note the 'id:'):

area(id:3600058447,3600058437,3600058446); // England, Wales, Scotland
permanent link

answered 09 Nov '20, 12:38

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 13 Nov '20, 19:32

Thanks for solution! It is very interesting trick with id's, that I don't know before.

(09 Nov '20, 12:42) Murz

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

question asked: 09 Nov '20, 09:34

question was seen: 2,102 times

last updated: 13 Nov '20, 19:32

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