Spain administrative boundaries
19 autonomous communities, 52 provinces and 8,132 municipalities, each with its official code, in GeoJSON, TopoJSON, GeoPackage, Shapefile, layered SVG, CSV and SQL.
The package also includes Andorra, in a folder of its own with the same files: it is not sold on its own.
- autonomous communities
- 19
- provinces
- 52
- municipalities
- 8,132
- postal code zones
- 13,886
- edition
One of the examples in the package
A layered SVG coloured from a table with a few lines of plain JavaScript: every entity is a path whose id is its official code. The page shows a part of the country: the two levels share the same borders, so they fit without gaps. The package has every entity of every level.
Catalonia: the municipalities of the province of Barcelona, coloured by area, among the other provinces.
What is in the package
Levels and identifiers
| Level | Entities | Identifier |
|---|---|---|
| country | 1 | ES |
| autonomous communities | 19 | ES-R-<official code> |
| provinces | 52 | ES-P-<official code> |
| municipalities | 8,132 | ES-M-<official code> |
| postal code zones | 13,886 | ES-Z-<official code>-<postal code> |
Every entity has the same identifier in every file: it is the feature id in GeoJSON and TopoJSON, the id of the path in SVG and the id column of the tables.
Formats and scales
| Format | full | 100m | 1km | 10km | light |
|---|---|---|---|---|---|
| GeoJSON | 123.9 MB | 17.9 MB | 4.3 MB | 50 KB | 821 KB |
| TopoJSON | 22.3 MB | 5.8 MB | 3.0 MB | 25 KB | 553 KB |
| Shapefile | 102.2 MB | 14.6 MB | 3.5 MB | 39 KB | 667 KB |
| SVG | - | 18.6 MB | 4.1 MB | 52 KB | 870 KB |
full: the boundaries as published by the source.100m: simplified within 100 m and coherent: municipalities, provinces and autonomous communities share exactly the same border vertices.1km: simplified within 1 km and coherent like100m, every level: the whole country on a web map.10km: simplified within 10 km and coherent, country, autonomous communities and provinces only: small maps and maps of many countries.- At the borders with the neighbouring countries (France and Portugal) the
100m,1kmand10kmboundaries share the same vertices as in their packages, so the maps fit without gaps or overlaps. light: country, autonomous communities and provinces only, each level simplified on its own to a small file.- GeoJSON: one FeatureCollection per level, WGS84. TopoJSON: all the levels in one topology, shared borders are shared arcs.
- GeoPackage:
data/geopackage/es.gpkg(137.2 MB), one file for QGIS and ArcGIS with every level at every scale as a layer (municipalities_100m) with its spatial index, and every table of the package. - Shapefile: one per level and scale, WGS84, UTF-8; the columns longer than ten characters are shortened (
region,province,abbrev). - SVG: one file per level and one with every level as a layer, in a Lambert conformal conic projection; they open as layers in Illustrator, Figma and Inkscape.
- Postal code zones:
data/geojson/postal_code_zones.geojson(72.6 MB), the municipalities divided by postal code, from the official addresses, in full detail; the identifier carries the official code of the municipalities and the postal code. Where there is one postal code the zone is the whole territory. - SQL: a script for PostGIS, one for MySQL 8 and one for SQL Server (18.0 MB each). It creates one table with every entity of every level, its
100mboundary in WGS84 and its indexes. - JSON:
data/json/tree.json(667 KB), the levels nested and sorted by name, without boundaries: what the select boxes of a form need.
Tables
CSV, UTF-8. Names in EN, IT, ES, FR, DE, NL, PT, besides the official one.
| File | Rows | Content |
|---|---|---|
tables/country.csv |
1 |
The country: names, population, bounding box, centre and label point.
code, name, population, min_lat, min_lng, max_lat, max_lng, center_lat, center_lng, label_lat, label_lng, id, name_en, name_it, name_es, name_fr, name_de, name_nl, name_pt
|
tables/regions.csv |
19 |
The autonomous communities: official code, names, area, population, bounding box, centre and label point.
code, name, area_km2, population, min_lat, min_lng, max_lat, max_lng, center_lat, center_lng, label_lat, label_lng, id, name_en, name_it, name_es, name_fr, name_de, name_nl, name_pt
|
tables/provinces.csv |
52 |
The provinces: official code, abbreviation, the code of the parent, names, area, population, bounding box, centre and label point.
code, name, abbreviation, region_code, area_km2, population, min_lat, min_lng, max_lat, max_lng, center_lat, center_lng, label_lat, label_lng, id, name_en, name_it, name_es, name_fr, name_de, name_nl, name_pt
|
tables/municipalities.csv |
8,132 |
The municipalities: official code, the codes of the parents, names, area, population, elevation in metres (of the centre, or lowest and highest point, as the official source gives it), bounding box, centre and label point.
code, name, province_code, province_abbreviation, region_code, cadastral_code, chief_town, area_km2, population, elevation, elevation_min, elevation_max, elevation_mean, min_lat, min_lng, max_lat, max_lng, center_lat, center_lng, label_lat, label_lng, id, name_en, name_it, name_es, name_fr, name_de, name_nl, name_pt
|
tables/postal_codes.csv |
14,152 |
The postal codes of the municipalities, one row for each pair; for the municipalities, with the identifier of the zone that postal code covers.
id, level, code, postal_code, zone_id
|
tables/codes.csv |
8,204 |
Every entity in other datasets, as Wikidata declares it: the Wikidata item, ISO 3166-2, GeoNames and the OpenStreetMap relation.
id, level, code, wikidata, iso_3166_2, geonames, osm_relation
|
tables/names.csv |
10,169 |
Every name an entity is written with (official, each side of a bilingual name, translated), without accents and as a slug: to match a file that has names and no codes.
id, level, name, name_ascii, slug, kind
|
tables/neighbours.csv |
48,584 |
The entities of the same level that share a border, both ways, with the length of the shared border in km.
level, id, neighbour_id, shared_border_km
|
tables/history.csv |
0 |
The suppressed municipalities with the one that replaced them, for archives that still have the old codes; no rows where the official source gives no history.
code, name, province_code, replaced_by_code, replaced_by_name
|
tables/changes.csv |
0 |
What changed from one edition of the package to the next, one row per entity added, removed, renamed, moved or with a new boundary: the same as CHANGELOG.md.
edition, date, level, id, name, change, before, after
|
Sources and licenses
The package is a derived work of the official datasets below; their publishers do not endorse it. What you may do with it is in the license of the packages.
- INE - Instituto Nacional de Estadística, Cifras oficiales de población de los municipios españoles (tabla 29005), licensed Condiciones de uso del INE: reutilización libre, también comercial
- IGN - Instituto Geográfico Nacional, Unidades administrativas (WFS INSPIRE), licensed CC BY 4.0
- Instituto Geográfico Nacional (CNIG), Sistema Cartográfico Nacional, CartoCiudad, portales y puntos kilométricos, licensed CC BY 4.0
- Wikidata, Labels and external identifiers of the administrative entities (translated names, codes in other datasets), licensed CC0 1.0
Files
All the 162 files of the package, with their size.
ATTRIBUTION.md | 3 KB |
|---|---|
CHANGELOG.md | 0 KB |
LICENSE.md | 2 KB |
README.md | 14 KB |
data/geojson/100m/country.geojson | 560 KB |
data/geojson/100m/municipalities.geojson | 14.5 MB |
data/geojson/100m/provinces.geojson | 1.7 MB |
data/geojson/100m/regions.geojson | 1.1 MB |
data/geojson/10km/country.geojson | 4 KB |
data/geojson/10km/provinces.geojson | 30 KB |
data/geojson/10km/regions.geojson | 15 KB |
data/geojson/1km/country.geojson | 59 KB |
data/geojson/1km/municipalities.geojson | 3.9 MB |
data/geojson/1km/provinces.geojson | 250 KB |
data/geojson/1km/regions.geojson | 146 KB |
data/geojson/full/municipalities.geojson | 83.5 MB |
data/geojson/full/provinces.geojson | 22.0 MB |
data/geojson/full/regions.geojson | 18.4 MB |
data/geojson/light/country.geojson | 39 KB |
data/geojson/light/provinces.geojson | 586 KB |
data/geojson/light/regions.geojson | 196 KB |
data/geojson/postal_code_zones.geojson | 72.6 MB |
data/geopackage/es.gpkg | 137.2 MB |
data/json/tree.json | 667 KB |
data/shapefile/100m/country.cpg | 0 KB |
data/shapefile/100m/country.dbf | 0 KB |
data/shapefile/100m/country.prj | 0 KB |
data/shapefile/100m/country.shp | 456 KB |
data/shapefile/100m/country.shx | 0 KB |
data/shapefile/100m/municipalities.cpg | 0 KB |
data/shapefile/100m/municipalities.dbf | 985 KB |
data/shapefile/100m/municipalities.prj | 0 KB |
data/shapefile/100m/municipalities.shp | 10.8 MB |
data/shapefile/100m/municipalities.shx | 64 KB |
data/shapefile/100m/provinces.cpg | 0 KB |
data/shapefile/100m/provinces.dbf | 4 KB |
data/shapefile/100m/provinces.prj | 0 KB |
data/shapefile/100m/provinces.shp | 1.4 MB |
data/shapefile/100m/provinces.shx | 1 KB |
data/shapefile/100m/regions.cpg | 0 KB |
data/shapefile/100m/regions.dbf | 1 KB |
data/shapefile/100m/regions.prj | 0 KB |
data/shapefile/100m/regions.shp | 905 KB |
data/shapefile/100m/regions.shx | 0 KB |
data/shapefile/10km/country.cpg | 0 KB |
data/shapefile/10km/country.dbf | 0 KB |
data/shapefile/10km/country.prj | 0 KB |
data/shapefile/10km/country.shp | 4 KB |
data/shapefile/10km/country.shx | 0 KB |
data/shapefile/10km/provinces.cpg | 0 KB |
data/shapefile/10km/provinces.dbf | 4 KB |
data/shapefile/10km/provinces.prj | 0 KB |
data/shapefile/10km/provinces.shp | 19 KB |
data/shapefile/10km/provinces.shx | 1 KB |
data/shapefile/10km/regions.cpg | 0 KB |
data/shapefile/10km/regions.dbf | 1 KB |
data/shapefile/10km/regions.prj | 0 KB |
data/shapefile/10km/regions.shp | 11 KB |
data/shapefile/10km/regions.shx | 0 KB |
data/shapefile/1km/country.cpg | 0 KB |
data/shapefile/1km/country.dbf | 0 KB |
data/shapefile/1km/country.prj | 0 KB |
data/shapefile/1km/country.shp | 48 KB |
data/shapefile/1km/country.shx | 0 KB |
data/shapefile/1km/municipalities.cpg | 0 KB |
data/shapefile/1km/municipalities.dbf | 985 KB |
data/shapefile/1km/municipalities.prj | 0 KB |
data/shapefile/1km/municipalities.shp | 2.1 MB |
data/shapefile/1km/municipalities.shx | 64 KB |
data/shapefile/1km/provinces.cpg | 0 KB |
data/shapefile/1km/provinces.dbf | 4 KB |
data/shapefile/1km/provinces.prj | 0 KB |
data/shapefile/1km/provinces.shp | 197 KB |
data/shapefile/1km/provinces.shx | 1 KB |
data/shapefile/1km/regions.cpg | 0 KB |
data/shapefile/1km/regions.dbf | 1 KB |
data/shapefile/1km/regions.prj | 0 KB |
data/shapefile/1km/regions.shp | 117 KB |
data/shapefile/1km/regions.shx | 0 KB |
data/shapefile/full/municipalities.cpg | 0 KB |
data/shapefile/full/municipalities.dbf | 985 KB |
data/shapefile/full/municipalities.prj | 0 KB |
data/shapefile/full/municipalities.shp | 67.8 MB |
data/shapefile/full/municipalities.shx | 64 KB |
data/shapefile/full/provinces.cpg | 0 KB |
data/shapefile/full/provinces.dbf | 4 KB |
data/shapefile/full/provinces.prj | 0 KB |
data/shapefile/full/provinces.shp | 18.1 MB |
data/shapefile/full/provinces.shx | 1 KB |
data/shapefile/full/regions.cpg | 0 KB |
data/shapefile/full/regions.dbf | 1 KB |
data/shapefile/full/regions.prj | 0 KB |
data/shapefile/full/regions.shp | 15.2 MB |
data/shapefile/full/regions.shx | 0 KB |
data/shapefile/light/country.cpg | 0 KB |
data/shapefile/light/country.dbf | 0 KB |
data/shapefile/light/country.prj | 0 KB |
data/shapefile/light/country.shp | 32 KB |
data/shapefile/light/country.shx | 0 KB |
data/shapefile/light/provinces.cpg | 0 KB |
data/shapefile/light/provinces.dbf | 4 KB |
data/shapefile/light/provinces.prj | 0 KB |
data/shapefile/light/provinces.shp | 471 KB |
data/shapefile/light/provinces.shx | 1 KB |
data/shapefile/light/regions.cpg | 0 KB |
data/shapefile/light/regions.dbf | 1 KB |
data/shapefile/light/regions.prj | 0 KB |
data/shapefile/light/regions.shp | 158 KB |
data/shapefile/light/regions.shx | 0 KB |
data/topojson/100m/es.topojson | 5.8 MB |
data/topojson/10km/es.topojson | 25 KB |
data/topojson/1km/es.topojson | 3.0 MB |
data/topojson/full/es.topojson | 22.3 MB |
data/topojson/light/es.topojson | 553 KB |
examples/choropleth-svg.html | 958 KB |
examples/drill-down-d3.html | 641 KB |
examples/leaflet-geojson.html | 589 KB |
examples/lib/LICENSES.md | 3 KB |
examples/lib/d3.min.js | 273 KB |
examples/lib/leaflet.css | 14 KB |
examples/lib/leaflet.js | 144 KB |
examples/lib/topojson-client.min.js | 7 KB |
examples/point-lookup.html | 1.7 MB |
flags/ES-R-03.svg | 4 KB |
flags/ES-R-04.svg | 6 KB |
flags/ES-R-05.svg | 148 KB |
flags/ES-R-07.svg | 134 KB |
flags/ES-R-08.svg | 29 KB |
flags/ES-R-09.svg | 0 KB |
flags/ES-R-10.svg | 20 KB |
flags/ES-R-11.svg | 0 KB |
flags/ES-R-12.svg | 90 KB |
flags/ES-R-13.svg | 1 KB |
flags/ES-R-15.svg | 434 KB |
flags/ES.svg | 58 KB |
sql/mysql.sql | 18.2 MB |
sql/postgis.sql | 18.0 MB |
sql/sqlserver.sql | 18.2 MB |
svg/100m/layers.svg | 9.4 MB |
svg/100m/municipalities.svg | 7.6 MB |
svg/100m/provinces.svg | 953 KB |
svg/100m/regions.svg | 604 KB |
svg/10km/layers.svg | 27 KB |
svg/10km/provinces.svg | 16 KB |
svg/10km/regions.svg | 9 KB |
svg/1km/layers.svg | 2.1 MB |
svg/1km/municipalities.svg | 1.8 MB |
svg/1km/provinces.svg | 134 KB |
svg/1km/regions.svg | 79 KB |
svg/light/layers.svg | 445 KB |
svg/light/provinces.svg | 318 KB |
svg/light/regions.svg | 107 KB |
tables/changes.csv | 0 KB |
tables/codes.csv | 451 KB |
tables/country.csv | 0 KB |
tables/history.csv | 0 KB |
tables/municipalities.csv | 1.7 MB |
tables/names.csv | 731 KB |
tables/neighbours.csv | 2.0 MB |
tables/postal_codes.csv | 756 KB |
tables/provinces.csv | 10 KB |
tables/regions.csv | 4 KB |
The package of Spain is not on sale yet. You can try it now: get the free sample, Extremadura (2 provinces and 388 municipalities) with the same files and formats.