Postal Codes Dataset for Spain, ES

734
Updated:
Files:1
Size:1.95 MB
Rows:14,538
Formats:csv
License:CC-BY-4.0

Postal Codes Dataset for Spain, ES including name of the city, town, or place, various administrative divisions and alternative city names.

Part of a Data Solution

  • Postal Codes Solution

    Every worldwide postal-code dataset in one bundle — the ultimate global reference for precise postal codes.

    Explore →

Premium

You're viewing a free sample

Get the complete dataset — all rows and files — delivered instantly after checkout, with lifetime access to the latest version.

  • Secure checkout via Stripe
  • Instant download after payment
  • Lifetime access to the latest version
  • Creative Commons Attribution 4.0 International license
20% off
$99.90$79.92
one-time payment

API Access

Access dataset files directly from scripts, code, or AI agents.

Browse dataset files
Dataset Files

Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.

/logistics/postal-codes-es/
https://datahub.io/logistics/postal-codes-es/_r/-/.licensing-notes.md
https://datahub.io/logistics/postal-codes-es/_r/-/.migration-notes.md
https://datahub.io/logistics/postal-codes-es/_r/-/ATTRIBUTION.txt
https://datahub.io/logistics/postal-codes-es/_r/-/README.md
https://datahub.io/logistics/postal-codes-es/_r/-/datapackage.yaml
Key Files

Start with these files — they give you everything you need to understand and access the dataset.

datapackage.yaml— metadata & schema
https://datahub.io/logistics/postal-codes-es/_r/-/datapackage.yaml
README.md— documentation
https://datahub.io/logistics/postal-codes-es/_r/-/README.md
Typical Usage
  1. 1. Fetch datapackage.yaml to inspect schema and resources
  2. 2. Download data resources listed in datapackage.yaml
  3. 3. Read README.md for full context

Data Files

postal-codes-es-sample


About this dataset

Postal Codes Dataset for Spain (ES)

This dataset lists Spanish postal codes (códigos postales) across every autonomous community, every province and every municipality. Rows carry the INE administrative codes at all three tiers and a coordinate.

Column definitions, row count, size and last-updated date are in datapackage.yaml.

Data Sources

  • Obra derivada de CartoCiudad 2026 CC-BY 4.0 scne.es: Instituto Geográfico Nacional / CNIG, under Orden FOM/2807/2015, CC BY 4.0. Provides the postal code to municipality relations and the postal-code coordinates.
  • Elaboración propia con datos extraídos del sitio web del INE: www.ine.es: Relación de municipios y sus códigos por provincias (update date in ATTRIBUTION.txt). Provides the municipality, province and community reference. The INE neither participates in nor endorses this dataset.
  • © GeoNames, CC BY 4.0: independent cross-check, municipalities the CartoCiudad layer misses, and locality names.

Changes made to the source data: postal code to municipality relations deduplicated and joined to the INE municipality register; municipality names with a trailing article put in natural order ("Coruña, A" becomes "A Coruña"); community codes given as ISO 3166-2:ES; locality names from GeoNames added as alternative city names; coordinates rounded to 5 decimal places; PO-box and large-customer codes added from a committed reference table, with the municipality's median coordinate.

Not endorsed by, or affiliated with, the Instituto Geográfico Nacional, CNIG, the INE or GeoNames.

All sources are CC BY 4.0 and this dataset is distributed under the same licence. No share-alike source (OpenStreetMap, Wikipedia) was used, so nothing here is encumbered by ODbL or CC BY-SA.

Known limitations

  • A postal code is not one-to-one with a municipality. Some codes span more than one municipality, while a large city holds many codes. The primary key is (postal_code, admin_code3), never postal_code alone; joining on the code by itself will fan out.
  • A code's first two digits identify the serving post office, not the municipality's province, so a few rows legitimately differ: Condado de Treviño is a Burgos enclave entirely surrounded by Álava and carries 01118; Petilla de Aragón is a Navarrese exclave inside Zaragoza and carries 50686; Tresviso is in Cantabria but its only road reaches the network through Asturias, so it carries 33554. admin_name2 / admin_code2 always give the municipality's real province. For the routing province, take the code's first two digits.
  • accuracy has two tiers. POSTAL_CODE is a point resolved for that individual five-digit code. MUNICIPALITY marks PO-box and large-customer ranges (XX070, XX071, XX080, plus installation codes such as a nuclear plant and an airport); these have no street geography, so the point is the median of the per-code points resolved inside their municipality. Coordinates are WGS84 / EPSG:4326, decimal degrees, 5 decimal places. No coordinate is interpolated or invented; where the geocoder has no point the cell is empty.
  • Some postal codes assigned to individual hamlets and installations are not included (03459, 10150, 15591, 19131, 28851, 34260, 37467, 37608, 43518, 43729, 45489, 50176). No open source states which municipality they belong to, and two carry a postal prefix from a different province than their name suggests, so assigning one would be a guess.
  • PO-box and large-customer codes come from a frozen reference table, so a code added later by the postal operator does not appear until that table is updated.

Municipality names

Names are given in natural reading order. The Spanish statistical register writes Coruña, A and Madrid, Comunidad de; this dataset ships A Coruña and Comunidad de Madrid, keeping the register form in alternative_city_name. Bilingual official names are preserved in full (Alacant/Alicante, Araba/Álava).

Administrative codes

admin_code1 is the ISO 3166-2:ES autonomous-community code with the ES- prefix stripped (AN, CT, MD…). admin_code2 is the INE two-digit province code. admin_code3 is the INE five-digit municipality code (CPRO+CMUN), the standard join key for Spanish statistical, cadastral and electoral data. All three are strings with significant leading zeros: read them with dtype=str or through the Data Package schema, or 04013 will silently become 4013.

Usage

The dataset files are available in CSV format and can be accessed and downloaded using the links provided in datapackage.yaml. Read postal_code as text, never as a number: Spanish codes can start with zero (01118).

For other inquiries, contact datahub@datopian.com