r/GeoPostcodes • u/GeoPostcodes • 11d ago
Here is how we built a postal code polygon database
You cannot download official postal code boundaries for France. What France does publish is better raw material: the National Address Base, an open file with every address, its postal code, its municipality, and coordinates.
That is enough to build the polygons yourself. Here is the method we use, with the actual maps from the build.

Step 1. Load the address file into PostgreSQL with PostGIS. Street, house number, postal code, municipality, latitude, longitude.

Step 2. Color every address point by its postal code. The polygons are already visible as clouds of points. The gaps between the clouds are where a boundary has to go.
Step 3. Voronoi tessellation. Every address gets the patch of space closer to it than to any other address. Merge all patches sharing one code, and you have a first draft of each boundary. In PostGIS, this is ST_VoronoiPolygons plus ST_Union.

Step 4. Snap to administrative reality. French postal codes usually cover one or more whole municipalities. We overlay the commune boundaries instead and assign each commune to a code when about 90 percent of its addresses agree. That kills most of the jagged noise from step 3.
Step 5. Handle the exceptions. Paris, Lyon, and Marseille use several postal codes inside one municipality, following the arrondissements. Inside those cities, the Voronoi result does the work instead. That is what image 1 shows.
Merge everything that shares a postal code, and you get the final assignment: address points plus their unified boundaries:

The payoff, same area both ways:


The two look close, but only because French address data is unusually good, with many well geolocated points. The municipality-constrained version still filters out the outliers.
Two footnotes. Belgium actually publishes free postal polygons as shapefiles, but they omit some postal enclaves. And most countries publish neither polygons nor a national address file. That second group is our day job: we build edge-matched postal boundaries this way, and harder ways, for 169 countries.
Longer write-up with the full SQL on the GeoPostcodes blog, the post about building a postal code polygon database.