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

Overpass API: Get streets by postal code

0
1

I want to get every street in a postal code area, my code works fine for Germany

 [out:csv(name;false)];
area[postal_code="10115"]->.a;
way(area.a)[highway][name];
out;

But how can I query for other countries with postal code system? For example FIN or CH?

Thanks a lot :)

asked 14 Mar '17, 18:33

kampfkeks18's gravatar image

kampfkeks18
11112
accept rate: 0%

I think your query is incorrect as soon as there is another region somewhere in the world that also has postal code 10115.

(24 May '17, 15:01) escada

One Answer:

0

I think the closest you can get without having postal_code areas defined is:

[out:json][timeout:25];
// fetch area “Polska” to search in
{{geocodeArea:Polska}}->.searchArea;
// gather results
(
  node["addr:postcode"="04-035"](area.searchArea);
  way["addr:postcode"="04-035"](area.searchArea);
  relation["addr:postcode"="04-035"](area.searchArea);
)->.addr;
way["highway"]["name"](around.addr:20.0);
out body;
>;
out skel qt;

But it's not ideal, as far as I know no address at Ostrobramska has postal code 04-035. You may try to change the radius at around.addr: to smaller than 20.0 metres

answered 24 May '17, 12:16

rmikke's gravatar image

rmikke
153
accept rate: 0%

edited 24 May '17, 12:21

Source code available on GitHub .