I am really new to the OSM query language and I want to know how to find the relation id from the area id.
Here is the query that I made:
is_in(45.5697, 3.1572);
foreach(area._["boundary"~"(administrative|national_park)"];out ;>;out;);
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI found the solution:
[out:json ];
is_in(45.5697,3.1572)->.a;
(
rel(pivot.a)[boundary=administrative][admin_level=8];
rel(pivot.a)[boundary~"(protected_area|national_park)"];
);
out ;
rel(pivot)
is probably the most convenient approach. According to the Wiki, area ids can also to be derived from an existing OSM way by adding 2400000000 to its OSM id or in case of a relation by adding 3600000000 respectively. That in turn means that an area id doesn't always have to reference a relation id. Also, note that some special extraction rules apply, i.e. there's not always an area available for each single way or relation.