4

I try to download the state borders of France (a few dozen states, not big data). Indeed I look for borders I can upload in my postgres database to localize POIs. OpenstreetMap seemed to be the good data source so I have tried to learn Overpass QL but it seems harder than I thought to do so... After some wiki reading I came to this:

way["name:en"="France"];
way["type"="boundary"];
way["boundary"="administrative"];
way["admin_level"="4"];

But the query endless runs... I am not sure about the query I made, is this the good syntax ? Thanks

Tom-db
  • 6,528
  • 3
  • 30
  • 44
Thomas Perrin
  • 675
  • 1
  • 8
  • 24

1 Answers1

10

There are several issues with your query:

  1. Administrative boundaries are frequently modeled as relations, rather than ways in OSM. So querying for ways way[...] will not return the result you're looking for.
  2. To fetch elements which have have several tags, you need to combine them like [key1=value1][key2=value2]. You current query would query ALL ways WORLDWIDE with type=boundary and then again WORLDWIDE all ways with admin_level=4. Obviously this is both very expensive and not what you're looking for.
  3. out statement is mandatory to return some result. In your case, the query would in fact run, but it would never return anything.

My recommendation is to use the following query instead:

rel["ISO3166-2"~"^FR"]
   [admin_level=4]
   [type=boundary]
   [boundary=administrative];
out geom;

Try it in overpass turbo: http://overpass-turbo.eu/s/lnv

mmd
  • 3,423
  • 1
  • 16
  • 23
  • Thanks a lot this is what I need – Thomas Perrin Jan 24 '17 at 09:34
  • I pushed a little forward and tried to get all the city boundaries from France. Based on what you told me for states, I tried the same but with level_admin=8 for cities. But there is no ISO3166 tag for city boundaries, actualy no country tag at all in the admin_level 8 boundaries. How can I search for all city boundaries of a specific country? Thanks! rel["ISO3166-2"~"^FR"] [admin_level=8] [type=boundary] [boundary=administrative]; out geom; – Thomas Perrin Feb 08 '17 at 16:34
  • @ThomasPerrin do you solve this? I'm looking for a way to do the same – David Sep 04 '17 at 22:46
  • 1
    I @David, no I didn't, I gave up this way to do it, I am now using the awesome website "OSM Boundaries 4.2" https://osm.wno-edv-service.de/boundaries/, it provides all the administrative boundaries of the world with an API service to download data – Thomas Perrin Sep 06 '17 at 11:11
  • @ThomasPerrin has it some documetation and an API to get the data? – David Sep 07 '17 at 01:15
  • Sorry for the late answer, yes it has, click on the "info/help" button on the upper right, it will show you a new panel with everything. There is an API (lower panel). Here is the link to the documentation: https://wambachers-osm.website/index.php/projekte/internationale-administrative-grenzen/boundaries-map-4-2-english-version. – Thomas Perrin Sep 11 '17 at 11:50
  • To test the API simply select an administrative border in the browser of the left panel, in the lower panel select API then click on the EXPORT button – Thomas Perrin Sep 11 '17 at 11:53