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

Overpass: Get postcodes-boundarys from area

0

Hello!

I try to get all postcodes from a area like "Munich". I tried:

<area-query ref="3600062428" />
 <recurse type="node-relation" />
 <query type="relation">
   <item />
   <has-kv k="boundary" v="postal_code"/>
 </query>
<print />

but the result is just empty. Any ideas how to do it? What I need are just the postcodes itself.

asked 07 Feb '13, 13:39

wuschba's gravatar image

wuschba
41225
accept rate: 0%

edited 07 Feb '13, 13:40


One Answer:

4

Yes, please use "recurse type='up'" instead.

<area-query ref="3600062428" />
  <recurse **type="up"** />
  <query type="relation">
    <item />
    <has-kv k="boundary" v="postal_code" />
  </query>
<print />

Postal code boundaries are made of ways which in turn are made of nodes, so there is no direct connection between the nodes and the relations. For that reason, the recurse node-relation doesn't find anything. By contrast, recurse "up" searches also for these indirect memberships.

answered 08 Feb '13, 07:42

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

edited 08 Feb '13, 07:44

Any idea why this won't work in Austria? Apetlon, 3600105619, should have the postcodes: 7132,7143,7161 but the result of the query

node(area:3600105619);
<;
relation._["boundary"="postal_code"];
out;

stays empty.

(21 Feb '13, 13:57) wuschba

Got a 2nd problem: The node for "Ingolstadt" gives me these postcodes: <tag k="postal_code" v="85049,85051,85053,85055,85057"/>

But doing your query on 3600062381, I get much more postcodes. What might be the problem?

(21 Feb '13, 14:08) wuschba

Source code available on GitHub .