Simplified access for administrative entities?

Posted by rayKiddy on 9 July 2015 in English (English)

Is there any single way to get information about administrative entities? It seems to me that there is a class of map users who are interested in admin entities. Perhaps they are interested in city boundaries. In the US, there may also be school districts, water districts and open space districts.

Once one has an id of some relation, it seems ok to get information about that entity.

But I have tried a couple of times to discover how to find these entities and I keep hitting a wall.

I can construct OverPass queries for these things, but they do not work and it is hard to see why they do not work. It is sort of like that old joke: How many prolog programmers does it take to screw in a lightbulb? false.

Here are queries I have tried:

relation [“boundary”=”administrative”] [“is_in:country”=”USA”] [“is_in:state”=”CA”] [“admin_level”=”8”] [“border_type”=”city”]; out body;


 <?xml version="1.0" encoding="UTF-8"?>
 <osm version="0.6" generator="Overpass API">
 <note>The data included ....</note>
 <meta osm_base="2015-07-09T21:00:02Z"/>

Hm. Not too helpful.

relation [“is_in:country”=”USA”] [“is_in:state”=”CA”] [“admin_level”=”8”] [“border_type”=”city”]; out body;

relation [“is_in:country”=”USA”] [“is_in:state”=”CA”] [“border_type”=”city”]; out body;


relation [“is_in:country”=”USA”] [“is_in:state”=”CA”] [“name”=”Ramon Road”]; out body;

relation [“is_in:country”=”USA”] [“is_in:state”=”CA”] [“name”=”Sunnyvale”]; (._;>;); out body;

Comment from maxerickson on 10 July 2015 at 00:07

Sunnyvale has “is_in:state” set to California:

Fix that and the last query should work. An alternative way to limit the geographic scope, that is not as reliant on tagging, is the search area feature of Overpass API:

Overpass Turbo adds a convenience function for this, so putting something like “name=Sunnyvale in California” into the wizard will construct almost the right query:

(click Run to see the result)

Of course, you probably aren’t interested in the street, but that is easy to fix, just prune out the way query (or maybe add another filter). Here’s the Overpass Turbo wizard query pruned down to something that Overpass API will be able to understand on it’s own:

It looks like you’ve got if figured out, but the “>;” and the extra “out;” statement are important, they tell Overpass API to recurse through the relation and return the members of it, and all the nodes that are part of the member ways.

There are also prepared extracts, Mapzen makes one set, I think there are others:

Comment from mmd on 10 July 2015 at 17:57

Do you know OSM Boundaries Map made by user wambacher? That’s probably all you need:

Login to leave a comment