Hello, I am fairly new to overpass but I attempt to do a tree traversal of boundaries of admin_levels for a given country.

For example: For UK, I want the UK border. Then on next level the borders of Wales, England, Scotland, Northern Island. Then on next level, for example inside England, I want the regions of England. Etc. At the end I would have a tree structure. I don't need to have all data all at once, but would be sufficient to get the data admin_level by admin_level.

I see 2 issues I am currently blocked.

First, I get the borders of 4 countries in UK. Can this query be optimized? I also get the nodes (capital), but I am only interested in the borders?

[out:json];
rel(62149); //UK
map_to_area;
rel(area)[admin_level=4][boundary=administrative];
out geom;

Second, how do I get the children for a given country? I could increment the admin_level but some admin_levels are not used. Is it better to query for admin areas inside an area?

[out:json];
rel(58447); //England
map_to_area;
rel(area)[admin_level=5][boundary=administrative];
out geom;

This seems excessively slow and many queries. What can be optimized?

asked 11 Aug, 10:04

Seraphis's gravatar image

Seraphis
112
accept rate: 0%


Unsure what you want your output to contain or what you want to use it for, but that would large amounts of data put a lot of strain on OP servers. If you're after full data https://osm-boundaries.com/ is recommended.

If you're after a list of names:

[out:csv(name,::id; false; ",")];
area(3600058447); //England
rel(area)[admin_level=5][boundary=administrative];
out tags;

3600000000 is the start number for relation's ids https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_element_id

RegEx can be used to search for different admin_levels in one call.

[out:csv(name,::id; false; ",")];
area(3600062149); //UK
rel(area)[admin_level~"[4,5]"][boundary=administrative];
out tags;
permanent link

answered 11 Aug, 13:26

DaveF's gravatar image

DaveF
2.3k6780110
accept rate: 10%

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:

×445
×191
×58
×4

question asked: 11 Aug, 10:04

question was seen: 188 times

last updated: 11 Aug, 13:26

powered by OSQA