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

Hey there! I was trying to figure out if it would be possible to get all postal codes within a specific radius around a given postal_code. For Bonn I tried:

http://overpass-api.de/api/interpreter?data=[out:json];area(around:10000)[postal_code="53111"]->.a;node(area.a)["addr:postcode"]["addr:postcode"!="53111"];out;

..but gives me no results. Does around work with area?

asked 14 Aug '14, 09:42

Korbi's gravatar image

Korbi
26113
accept rate: 0%

edited 15 Aug '14, 06:18

mmd's gravatar image

mmd
5.7k15388


From looking at the code I would say that around is indeed not yet implemented for areas. You might want to raise an issue for this on github. However, you could as well use the corresponding relation and run around on the relation instead:

area[boundary=postal_code][postal_code="53111"];rel(pivot);(rel(around:10000)[boundary=postal_code][postal_code][postal_code!="53111"];>;);out;

Try it on overpass turbo

In fact, you can skip the area part altogether and start with the relation for a simpler approach:

rel[boundary=postal_code][postal_code="53111"];(rel(around:10000)[boundary=postal_code][postal_code][postal_code!="53111"];>;);out;

Try it on overpass turbo

BTW: In your overpass api query you seem to check for nodes with "addr:postcode". This doesn't exactly match your question where you wanted to find postal codes within a given radius around a specific postal code. Maybe you want to rephrase your question a bit to clarify what you are looking for.

A slightly modified version of the last query will return all relevant relations. In a post-processing step, you'll have to extract the postal code from the relations to get a list of postal codes:

rel[boundary=postal_code][postal_code="53111"];rel(around:10000)[boundary=postal_code][postal_code][postal_code!="53111"];out;

Try it on overpass turbo (you can ignore the warning message when executing the query)

permanent link

answered 15 Aug '14, 06:21

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

edited 15 Aug '14, 09:28

Well I was actually looking for an opportunity to get all postal codes within a specific radius. Let's say, I do have Bonn's postal code and would like to get all postal codes within a radius of 10.000m calculated from Bonn's postal code area (or its center). I'm not very much interested in all border nodes, streets etc, I just would like to get the postal codes within the given radius. Does this clarify my problem?

EDIT: I think I'm gettin closer now: rel[boundary=postal_code][postal_code="53111"]->.a;(rel(around.a:10000)[boundary=postal_code][postal_code][postal_code!="53111"][postal_code_level][type="boundary"];);out;

(15 Aug '14, 09:21) Korbi
1

Ok, I've updated my reply. Note that you'll have to do some kind of post processing on the result to extract a list of postal codes from the list of relations. However, this should be straightforward.

(15 Aug '14, 09:29) mmd

Thanks for your help, it seems our answers just crossed ;)

(15 Aug '14, 09:38) Korbi

Hello, I have exactly the same need and the query suits me perfectly :

rel[boundary=postal_code][postal_code="53111"];rel(around:10000)[boundary=postal_code][postal_code][postal_code!="53111"];out;

I just want to specify the country of the postal code in my query. Can you help me!

permanent link
This answer is marked "community wiki".

answered 05 Jan '22, 08:16

AYADI's gravatar image

AYADI
11
accept rate: 0%

edited 05 Jan '22, 08:17

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:

×483
×213
×16
×10

question asked: 14 Aug '14, 09:42

question was seen: 8,481 times

last updated: 05 Jan '22, 08:17

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