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

2
1

Hello,

I have found the website "OSM Boundaries Map 4.1" on https://wambachers-osm.website/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)]
   [type=boundary]
   [boundary=administrative]
   [ (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 '17, 18:07

thomas_bilendi's gravatar image

thomas_bilendi
41114
accept rate: 0%

edited 05 Jul '17, 08:19

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273

Have you solved this problem since then?

(01 Jul '17, 23:10) meglio

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 '17, 18:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
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 '17, 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 '17, 20:32

Hjart's gravatar image

Hjart
3.0k42656
accept rate: 18%

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 '17, 10:53) thomas_bilendi

This website presents the boundaries hierarchically using admin_level: https://osm-boundaries.com

permanent link

answered 27 Apr '22, 10:42

pcgomes's gravatar image

pcgomes
1
accept rate: 0%

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:

×362
×129
×65

question asked: 14 Feb '17, 18:07

question was seen: 12,277 times

last updated: 27 Apr '22, 10:42

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