I have found the website "OSM Boundaries Map 4.1" on https://osm.wno-edv-service.de/boundaries/, it shows exactly what I would like to perfom with its exploring tree: for a given country I would like to get all the lower admin_levels and their administrative boundaries. So I tried to find the queries allowing me to get the boundaries for each admin_level of a given country.

From levels 2 to 4 it's ok and quite simple, I came succesfully to the generic query:

rel[admin_level=(level number)]
   [ (specific tag to identify the country, see below) ];
out geom;

--With the specific tags to identify the country (with XX=iso2 country code):
admin_level=2 > ["ISO3166-1"~"^XX"]
admin_level=3 > ["is_in:country"="XX"]
admin_level=4 > ["ISO3166-2"~"^XX"]

But after that I encounter two issues: - I can't find a generic query effective for all the countries - I can't link lower admin_level to its upper admin_level (or inversely)

Indeed, from level 5 I can't find any generic query I could use in any country. Indeed the different countries in the world will have specific tags in their admin_levels or won't have tag at all identifying the country. For example admin_level=5 "Greater London" in England doesn't have any tag identifying the country or upper level identification. Admin_level=6 "London" has the following tag to identify "is_in:iso_3166_2"="GB-ENG", but admin_level=6 "Nord" in France has a different tag: "ISO3166-2", not the "is_in" tag. Last example, for all cities in France (admin_level=8), I can't find any tag linked to the country or at list the upper level.

I found out that some levels has a "subarea" mentionned, but it's not in all levels. The only solution I have at the moment is to search all boundaries whose the "admin_center" is in the upper boundary, but it's very heavy to perform on all admin levels of all countries...

Do you know how I can get all administrative boundaries of all admin_level of a given country? Thanks

asked 14 Feb, 18:07

thomas_bilendi's gravatar image

accept rate: 0%

Trying to do that with Overpass is probably not a good idea as you rely on structures that may or may not be there (even the admin_centre is not guaranteed to be set). Did you notice the wno-edv-service.de web site has a download option?

I'd recommend loading the OSM data for your area of interest into a database with osm2pgsql (you can use a much reduced style file on import if you're only interested in administrative areas). After that, you can use the power of PostGIS to answer questions like "give me all admin boundaries that are inside this polygon" and so on. And you can easily export to GeoJSON or Shape files.

permanent link

answered 14 Feb, 18:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Hi Frederik, Yes I have seen the download section, but since this service is kindly provided by a private individual, it could stop at any moment. So this is why I wanted to be able to query myself directly osm data.

Indeed, I could load the osm data for my area into my postgis db then query it, but this is a huge amount of data and that's why I try to find the query to download only admin_levels (I will have to download data every month). After that, as you said, I can use PostGIS and query the imported boundaries.

(15 Feb, 10:46) thomas_bilendi

For a country where it works (i.e. Denmark) you can try boundary=administrative & type:relation in Danmark in the Overpass Turbo wizard (replace "Danmark" with the name of your preferred country).

permanent link

answered 14 Feb, 20:32

Hjart's gravatar image

accept rate: 0%

Hi Hjart, Yes I can, but its not the same for every country, and even in Denmark some admin_levels (e.g. admin_level=7) don't have that country tag (specific example: rel(2190242). So what I try to find is how the admin_levels are linked to each other

(15 Feb, 10:53) thomas_bilendi
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



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:


question asked: 14 Feb, 18:07

question was seen: 87 times

last updated: 15 Feb, 19:28

powered by OSQA