OpenStreetMap merkið OpenStreetMap

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;

result:

 <?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"/>
 
 </osm>

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;

Nothing…..

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;

Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Umræða

Athugasemd eftir maxerickson sett inn 10. júlí 2015 kl. 00:07

Sunnyvale has “is_in:state” set to California:

osm.org/relation/112145

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:

osm.wiki/Overpass_API/Overpass_QL#By_area_.28area.29

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:

http://overpass-turbo.eu/s/alc

(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:

http://overpass-turbo.eu/s/ald

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:

https://mapzen.com/data/borders/

Athugasemd eftir mmd sett inn 10. júlí 2015 kl. 17:57

Do you know OSM Boundaries Map made by user wambacher? That’s probably all you need: https://osm.wno-edv-service.de/boundaries/

Skrá inn til að bæta við athugasemd