0

I want to get the shapes of an area via overpass that is defined by the first two letters of the postal code. This query:

rel["boundary"="postal_code"][postal_code~"32..."];
out geom;

gets me a number of areas that I want to combine. I am interested in the path of the outer border, i.e. just a single large area instead of the many small ones.

You can see the result on http://overpass-turbo.eu/s/8il .

Is it possible to achieve this via an overpass query only? If not, what might be the most efficient way to provide a JavaScript application with the desired result?

1 Answers1

1

Overpass API doesn't support this out of the box. After retrieving all relevant postcode relations from Overpass API, you need something like a concave hull post-processing step. As you pointed out in the comment below, one example to accomplish this in Javascript could be http://andriiheonia.github.io/hull/. You might also take a look at gis.stackexchange for alternative approaches (https://gis.stackexchange.com/questions/tagged/concave-hull).

If you just want to tweak the appearance in Overpass Turbo to make the polygons appear like one large area, you should take a look at the MapCSS features included. Here's a small example, which may be used as a starting point: http://overpass-turbo.eu/s/8la

enter image description here

BTW: I'd recommend to limit your query to a certain area/bbox, as your original query also returns some data from Russia.

Community
  • 1
  • 1
mmd
  • 3,423
  • 1
  • 16
  • 23
  • I totally agree that limiting the query is necessary. However, the best thing I could come up with is `{{geocodeArea:Germany}}->.searchArea; ( rel["boundary"="postal_code"][postal_code~"32..."](area.searchArea); ); out geom; ` This query does not seem to even terminate. At least it takes minutes instead of seconds now. Howto fix? – JanoschZacha Mar 20 '15 at 21:00
  • I just retried it. My first approach takes about 5 seconds. Including the geocodeArea means it takes roughly 1 minute. The bbox approach also needs 1 minute - and in its current version gives an empty result. It is really puzzling me that an restriction to the query should make it take longer than the unrestricted search. – JanoschZacha Mar 21 '15 at 09:20
  • I updated my previous answer, see new query above. Response time: 5s. – mmd Mar 21 '15 at 16:07
  • Thank you very much, I can confirm the response time this time. The approach of just making the small regions appear like a single region by removing the visual borders might work for me for now. Let's add some hints to your answer, how one could further advance in the future. What we might want to calculate in the next step is the _concave hull_. There exists a JavaScript implementation of a fast algorithm on [github](https://github.com/AndriiHeonia/hull) for this. If necessary, we could output the overpass data in json format for this by adding [out:json]; in the first line. – JanoschZacha Mar 22 '15 at 09:22
  • Ok, great. I added a few more pointers to my answer. If you're satisfied now, don't forget to vote/accept the answer. Thanks – mmd Mar 22 '15 at 15:17