Hello,

I use the Overpass-API to get cities from some area. As an example I use this simple query:

node
["place"~"village|city|town|metropolis"]
["name"~"^A"]
(area:3602145268);
out body;

So I get a lot of villages/cities/towns/metropolises which starts with "A" which is fine so far.

What I need now are - besides the information the query above delivers in the node - all relation-ids to that found cities. How can it be done? Can the query above be modified to deliever all relation-ids as well? It would avoid sending a query for every city I got.

asked 14 Feb '13, 12:49

wuschba's gravatar image

wuschba
41225
accept rate: 0%

edited 14 Feb '13, 12:49


In principle, it is possible to get with this request all city boundaries in bavaria.

In detail, there are two things to consider: First, it also returns cities that have a common boundary with bavaria, although they are actually outside bavaria. This is a side effect of the query semantics I have not thought about: Ways are considered inside an area if they are completely on the border (which makes sense), and relations are considered inside if one or more of its elements are inside (which also makes sense on its own), but both together is a little bit odd.

Second, there is no connection between the place nodes and the boundary relations. In some cases, they may be contained as members in the boundary relations, but not always.

edit:

Ahh, now I understand your question better. This query finds all place nodes (I added those of type town to cover more places) and for each the area it belongs to. To simplify testing, I have restricted these again to "A..". Feel free to remove that condition, but the query then runs for several minutes.

You can in principle deduce the relation ids from the area ids: just substract 3.6 billion. However, if you want to query for postcodes and so on afterwards, it is likely that you anyway still need the area and not the relation. I've written about the issue in this forum thread.

permanent link

answered 15 Feb '13, 08:53

Roland%20Olbricht's gravatar image

Roland Olbricht
6.4k35986
accept rate: 35%

edited 15 Feb '13, 18:45

1

Thanks for your reply. When looking at:

http://nominatim.openstreetmap.org/details.php?place_id=97345357

or

http://nominatim.openstreetmap.org/details.php?place_id=3676853724 it seems I always get somewhere an "relation" for a city:

Munich: 62428

Ingolstadt: 62381

I need that to query all postcodes or streets for example via overpass to be used in the area-part of the request.

So I have nodes (cities) and need the relations like shown in nominatim - how would you do that with overpass?

(15 Feb '13, 14:45) wuschba

Hello wuschba, your aims seem to be a bit more than an FAQ for this site .. come to forum.openstreetmap.org, there is even a very active German sub forum if my assumption is right and you are from there.

If you get a solution for your aims, you can add it as an overpassAPI example in the collection in the OSM wiki, so others can benefit, too.

(15 Feb '13, 15:31) stephan75

Hi Stephan, thanks for your reply. So you suggest discussing this in "users:Germany" on forum.openstreetmal.org?! Or is it more something for "Developers"?

(15 Feb '13, 17:01) wuschba

I suggest "users:Germany".

(15 Feb '13, 18:31) Roland Olbricht
Your answer
toggle preview

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:

×355
×190
×155

question asked: 14 Feb '13, 12:49

question was seen: 8,508 times

last updated: 15 Feb '13, 18:45

powered by OSQA