4

I'd like to limit a query (for highways) by postal_code and country (since the postal_codes are only unique on a national level).

Let's say that is my query:

area[postal_code="19300"]->.searchArea;
area.searchArea[name="Germany"];
way(area.searchArea)[highway][name];
(._;>;);
out;

http://overpass-turbo.eu/s/QeG

By that I get highways in Germany and in France.

I thought about something like

area.searchArea[name="Germany"].->searchArea2;
way(area.searchArea2)[highway][name];

But this doesn't work.

What would be the correct syntax?

Or how could I link something like

{{geocodeArea:Germany}}

to this kind of query?

1

1 Answer 1

4

Overpass API does not support area in area queries. However, you can define two different areas and use both of them as filter criterion in the same statement:

area[postal_code="19300"]->.zip;
area[name="Deutschland"]->.de;
way(area.de)(area.zip)[highway][name];
(._;>;);
out;
2
  • 1
    Awesome! Quite sure I tried adding those to sets/areas like that, anyway thanks a lot! In the meantime I came across github.com/drolbr/Overpass-API/issues/45 and wiki.openstreetmap.org/wiki/Overpass_API/…. Is there any difference in those both approaches?
    – entenbein
    Jan 30, 2020 at 14:54
  • 1
    Yes, results could differ, if area2 has some parts which are outside of area1. The query here assumes that objects are both in area1 and area2. The other example you've quoted would only check, which area2 is inside area1 (there might be multiple differnet ones), and then only filters based on area2.
    – mmd
    Jan 30, 2020 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.