This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Get the bounding box of a city thanks to its ID

0

Hello, I'm using Overpass API and I'm looking for a way to get everything which is in a city determined by the ID of its node. For instance, If we're getting a closer look to London, it shows :

 <node id="**107775**" lat="51.5072759" lon="-0.1276597">
    <tag k="capital" v="yes"/>
    <tag k="ele" v="15"/>
    <tag k="is_in" v="England, United Kingdom, UK, Great Britain, Europe"/>
    <tag k="is_in:continent" v="Europe"/>
    <tag k="is_in:country" v="United Kingdom"/>
    <tag k="media:commons" v="https://commons.wikimedia.org/wiki/Category:London"/>
    <tag k="name" v="London"/>
    [...]
    <tag k="website" v="http://www.london.gov.uk/"/>
    <tag k="wikipedia" v="en:London"/>
  </node>

I'd like to get the bounding box of this city thanks to its node ID (here : 107775). I managed to do this thanks to the name of the city by the request : (rel["name"='London'];>;);out; But as you can see, in case of multiple places with the same name, you get multiple bounding box. That's the reason why I'd like to get this bounding box thanks to the ID of the node associated to the city.

So, to sum um, with this node : node(107775), is it possible to get the bounding box of the city ?

Thanks

asked 11 Apr '13, 12:20

Kobz's gravatar image

Kobz
1112
accept rate: 0%

edited 11 Apr '13, 12:22

I am not really sure that I understand your question (a bounding box based on a node?!?) - however, maybe it helps that many cities have their boundaries mapped like this: https://www.openstreetmap.org/browse/relation/62400 Note that this does not applies to every city (remarkably small ones) as OSM's data quality varies.

(13 Apr '13, 01:37) aseerel4c26 ♦

One Answer:

2

First of all, it seems that you are not looking for exact bounding boxes of a certain city, but for its boundary relation.

Main problem: the binding from a node to its boundary relation is not completley mapped in the OSM data. There are some countries where you have boundary relations with one node as a member with the role admin_centre ... thus you ca find all place nodes that are member of a boundary relation.

But this binding is incomplete in the world, even in Germany this data model is not so widely spreaded.

see Relation:boundary in the OSM wiki.

Maybe also helpful: overpass-get-relation-and-node-in-one-query-for-city

answered 15 Apr '13, 17:10

stephan75's gravatar image

stephan75
12.6k556210
accept rate: 6%

Source code available on GitHub .