Códigos postales de España provides estimated postal code areas for Spain, built from open address data from CartoCiudad and administrative boundaries. Explore the results on interactive maps and download the data for use in R, Python or QGIS.
Background
Postal code polygons are useful for linking addresses and statistics to areas on a map. According to Goerlich (2022), the Correos polygons available through CartoCiudad stopped being offered for download in early 2017. This project explores a reproducible alternative based on open address data.
An early reference is José Ignacio Sánchez’s 2020 article in NoSoloSIG, which describes how to estimate postal areas from CartoCiudad addresses using GIS tools. This project applies the approach developed in Francisco José Goerlich’s 2022 work, with its own choices for selecting addresses and handling areas without an assignment.
Maps and data
The project website includes interactive maps and two GeoPackage downloads: a full version for spatial analysis and a simplified version for visualization. Both include postal code areas and administrative areas pending assignment.
The data is shared under a Creative Commons Attribution 4.0 International license.
Interactive map
Search for a postal code or address, select a two-digit prefix and compare the estimated areas with CartoCiudad. The viewer uses the simplified data and does not display areas pending assignment. Its controls are in Spanish.
Open the map in a full window Viewer guide
Methodology
Following Goerlich’s approach, the workflow treats each separate component of an administrative area independently. When the selected addresses share a single postal code, it assigns that code to the whole component. When several codes are present, it builds Voronoi polygons around the address locations, clips them to the administrative boundary and merges areas with the same code. The final polygons are dissolved by postal code across provinces.
This implementation selects addresses using an inward buffer of 200 m, with a second attempt at 50 m if none are found, rather than the 20 m described by Goerlich. Components without selected addresses remain unassigned unless the municipality has a single postal code recovered from its other components. The administrative boundaries come from LAU2boundaries4Spain, by Francisco José Goerlich and Pedro Pérez Vázquez.
These are estimated areas, not official postal boundaries. Coverage depends on the source addresses and some areas remain unassigned. The repository documents the sources, methodology, limitations and steps to reproduce the data.
References
- Instituto Geográfico Nacional / Centro Nacional de Información Geográfica (IGN/CNIG). (n.d.). CartoCiudad [Dataset]. Data portal.
- Instituto Geográfico Nacional / Centro Nacional de Información Geográfica (IGN/CNIG). (n.d.). Servicios de visualización de CartoCiudad: direcciones y códigos postales. WMS documentation.
- Correos. (n.d.). Base de datos de códigos postales y capa cartográfica. Product information.
- Goerlich, F. J. (2022). Elaboración de un mapa de códigos postales de España con recursos libres. Cómo evitar pagar por disponer de información de referencia. Working Papers Ivie, no. 2022-3. Ivie. doi:10.12842/WPIVIE_0322.
- Goerlich, F. J., & Pérez Vázquez, P. (2025). Base de datos histórica de contornos municipales de España –LAU2boundaries4Spain– (version v2) [Dataset]. Zenodo. doi:10.5281/zenodo.15345101.
- Hernangómez, D. (2026). Códigos postales de España (version 1.0.0) [Dataset]. Zenodo. doi:10.5281/zenodo.23698418.
- Sánchez, J. I. (2020, November 13). Así hice el mapa de los códigos postales de España con SIG y datos abiertos. NoSoloSIG. Article.