4

I've got a collection of postal codes from all over the country. These are points. I need to determine the polygon areas from these points, for each of the postal codes.

That is: for example, I have a set of points labelled with the postal code 11-111. I need the program to determine for me from these points an area that contains all the points belonging to the category (something like the Convex Hull Algorithm), and then create a polygon based on it, for further use. Then it did the same with the next postal code (e.g. 11-112), and so on and so forth until the dataset runs out.

The final step is to save this as a .shp, so that in the future you can use this to apply data to this file.

My attempts to tackle the problem are below. I tried to do this using the "Bounding Geometry" function (or at least that's the name I hope it has in English; unfortunately I have QGIS in my native language). Unfortunately, the polygons overlap, which to my knowledge they shouldn't, and I'm wondering if I've done something wrong.

enter image description here

The second way was to convert points to bounding lines and then lines to polygons, but instead of the expected effect I got lines and very strange boxes.

enter image description here

enter image description here

Someone may have had a similar problem or just know how to solve such a problem?

(These strange huge triangular polygons are most likely problems at the level of the data itself-or rather, the zip codes are the same in only one area-but if anyone had an idea how to catch and fix them from within QGIS, I'd love to know, too)

6
  • 2
    Postal codes are linear, not areal, features. Your problem is assuming that they can be all represented as polygons.
    – Vince
    Commented Dec 23, 2022 at 14:09
  • You first attempt should works with the "Minimum bounding geometry" processing algorithm set to use "Convex Hull" geometry type and the field set to your postal code field, if your data is clean. you should make sure your data is correct, especially the more weird polygons
    – Kalak
    Commented Dec 23, 2022 at 14:10
  • 2
    You can try with Thiessen polygons. Postal code is not always straightforward and is even worst with user supplied data (addresses). For example, in my country we can have multiple postal code in the same building, or a postal code withing another one (ex: an hospital has its own PC, while the remaining of the street block has another one)
    – JGH
    Commented Dec 23, 2022 at 14:13
  • @Vince wouldn't it be country specific?
    – JGH
    Commented Dec 23, 2022 at 14:15
  • 1
    @Vince If postal codes in Poland work like they do in France where I live then each city has a postal code assigned to it or part of the city for big cities, which means each postal code can more or less be converted to an area
    – Kalak
    Commented Dec 23, 2022 at 14:20

2 Answers 2

9

Starting with a set of points with attribute "code", shown here as a label:

enter image description here

First use "Voronoi Polygons" to construct the polygons that divide the space up to the region nearest each point:

enter image description here

This is with a "Buffer region" of 0, so its clipped to the data. You might want to make a buffer bigger than that in the Voronoi Polygons dialog to get some border round your points.

Next use "Dissolve" and set the dialog to dissolve on the "code" field. Click the ... box in the "Dissolve field(s) (optional)" widget and chose your "code" field. Run it:

enter image description here

This has merged all the polygons with the same code. The code is inherited by the merged polygons, so you can label them:

enter image description here

Note that is you have polygons with the same code but a long way from each other, you might find that the merged polygons result in "Multipolygon" features - i.e. there are separate polygon rings in a single feature. This is normal for data like that.

3

Voronoi's as suggested by @spacedman is the right direction.

I am not sure about the source of your postcodes, if they are from openstreetmap then be aware that some of them may be wrong. Hence such large and unusual surfaces in your attempts. I did it a few years ago, and had similar issues. The data has to be cleaned a bit.

If the goal is to have the exact boundaries, then GUGiK has administrative boundaries as OpenData (https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WFS/AdministrativeBoundaries) - you can merge with your zip-codes. There is a address and streets register: https://mapy.geoportal.gov.pl/wss/ext/KrajowaIntegracjaNumeracjiAdresowej where you can find zip-codes, teryt and simc, what can be used to join with boundaries.

Your Answer

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

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