NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


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

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

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.


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
accept rate: 36%

edited 15 Feb '13, 18:45


Thanks for your reply. When looking at:

or 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, 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! Or is it more something for "Developers"?

(15 Feb '13, 17:01) wuschba

I suggest "users:Germany".

(15 Feb '13, 18:31) Roland Olbricht

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 14 Feb '13, 12:49

question was seen: 12,029 times

last updated: 15 Feb '13, 18:45

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum