| Type: | Package |
| Title: | Historical Municipal Boundaries of Spain (1900-2001) |
| Version: | 0.1.0 |
| Description: | Municipal boundaries of Spain for each population census between 1900 and 2001, together with provinces, judicial districts and electoral districts (Cortes of the Restoration in 1920 and constituencies of the Second Republic in 1931, 1933 and 1936) built from them, and the census figures of every municipality from 1842 to 2011. All maps derive from a single partition of the territory, so they have no gaps or overlaps and can be aggregated consistently. Boundaries of historical municipalities are an approximate reconstruction. Geometries are downloaded from 'Zenodo' <doi:10.5281/zenodo.23663208> and cached locally. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/pauvallprat/mapSpainHist, https://pauvallprat.github.io/mapSpainHist/ |
| BugReports: | https://github.com/pauvallprat/mapSpainHist/issues |
| Encoding: | UTF-8 |
| Language: | en-US |
| LazyData: | true |
| Depends: | R (≥ 4.1) |
| Imports: | sf, tools, utils |
| Suggests: | ggplot2, knitr, mapSpain, rmarkdown, s2, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Config/Needs/website: | pkgdown, scales |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-26 16:15:56 UTC; pau.vall |
| Author: | Pau Vall Prat |
| Maintainer: | Pau Vall Prat <pau.vall@ub.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-11 20:50:08 UTC |
mapSpainHist: Historical Municipal Boundaries of Spain (1900-2001)
Description
Municipal boundaries for each population census between 1900 and 2001, plus provinces, judicial districts and electoral districts built from them. All maps derive from a single partition of the territory, so they have no gaps or overlaps and aggregate consistently.
Warning
approximate boundaries: For most historical municipalities there is no cartography of their limits. Their polygons were reconstructed approximately from the earliest available official municipal division (early 2000s), making sure that the municipal seat (the settlement that usually names the municipality) and, when known, the other settlements of the municipality fall inside the polygon. The maps are especially useful to represent municipal data graphically, but they must be used with caution when geographic variables matter (area, distances, exact borders): they are a useful but imperfect approximation.
Licenses and sources
The package, including the bundled tables censos and unitats, is released under the MIT license. The data deposit on Zenodo from which the geometries are downloaded (doi:10.5281/zenodo.23663208) is released under the Creative Commons Attribution 4.0 International license (CC BY 4.0). The reference municipal boundaries derive from SIANE (Instituto Geográfico Nacional, CC BY 4.0); census figures come from the population censuses of the Instituto Nacional de Estadística (INE); municipal changes from Variaciones de los municipios de España desde 1842 (MINAP); the 1920 electoral districts from the source cited in the methodology.
The full methodology is available on the package website (in Catalan, Spanish and English).
Author(s)
Maintainer: Pau Vall Prat pau.vall@ub.edu (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/pauvallprat/mapSpainHist/issues
Census figures of Spanish municipalities, 1842-2011
Description
Population census data for every municipality and census edition, from
Municipis_Espanya_1842-2011.xlsx. A municipality is in force at a census when
hogares is not missing. Rows with no_munic == 1 are the non-municipal
territories (codes 53xxx) present in the maps, which have no census figures.
Usage
censos
Format
A data frame with columns:
- cod_ine
INE municipality code (5 characters; 6 for municipalities extinct before 1900).
- censo
Census year.
- municipio
Municipality name.
- prov
Province.
- cod_ccaa, ccaa
Autonomous community code and name.
- PJ
Judicial district (partido judicial).
- hogares
Households.
- pder
De jure population.
- phec
De facto population.
- pob_serie
Continuous population series.
- no_munic
1 for non-municipal territories (53xxx), 0 otherwise.
Historical electoral districts of Spain
Description
Electoral districts built by dissolving the municipalities of the census:
-
1920: districts for the Cortes of the Restoration, on the 1920 municipalities (Melilla has no district and is not included). -
1931,1933,1936: constituencies (circunscripciones) of the Second Republic, on the 1930 municipalities.
cod_unit has 4 digits: the province code and the district number
(alphabetical order within the province). Non-municipal territories (53xxx) are
assigned to the district of their province with which they share the longest
boundary.
Usage
esp_get_circ_hist(
year,
epsg = 4258,
moveCAN = FALSE,
census_data = TRUE,
cache_dir = NULL,
update_cache = FALSE,
verbose = FALSE
)
Arguments
year |
1920, 1931, 1933 or 1936. Census figures come from the 1920 census (1920) or the 1930 census (1931-1936). |
epsg |
EPSG code of the output (default 4258, ETRS89, as in mapSpain). |
moveCAN |
Position of the Canary Islands. |
census_data |
If |
cache_dir |
Cache directory. If |
update_cache |
If |
verbose |
If |
Value
An sf object with columns cod_unit, nom, n_mun and, optionally,
the census figures.
Examples
c1933 <- esp_get_circ_hist(1933, cache_dir = tempdir())
Historical municipalities of Spain for a census year
Description
Returns the municipalities in force at the given census. All census maps come from the same partition of the territory, so they have no gaps or overlaps and can be aggregated (provinces, judicial districts, electoral districts...) without slivers.
Usage
esp_get_munic_hist(
year,
epsg = 4258,
moveCAN = FALSE,
include_nonmunicipal = TRUE,
census_data = TRUE,
cache_dir = NULL,
update_cache = FALSE,
verbose = FALSE
)
Arguments
year |
Census year, one of |
epsg |
EPSG code of the output (default 4258, ETRS89, as in mapSpain). |
moveCAN |
Position of the Canary Islands. |
include_nonmunicipal |
If |
census_data |
If |
cache_dir |
Cache directory. If |
update_cache |
If |
verbose |
If |
Details
The geometries are downloaded from Zenodo the first time and stored in a cache
directory (see mhist_cache_dir()).
Value
An sf object with one row per municipality, or NULL (with a
message) if the geometries cannot be downloaded.
Warning
the boundaries of most historical municipalities are an approximate reconstruction. See mapSpainHist-package.
Examples
m1930 <- esp_get_munic_hist(1930, cache_dir = tempdir())
m1930_can <- esp_get_munic_hist(1930, moveCAN = TRUE, cache_dir = tempdir())
if (!is.null(m1930)) plot(sf::st_geometry(m1930))
if (!is.null(m1930_can) && requireNamespace("mapSpain", quietly = TRUE)) {
plot(sf::st_geometry(m1930_can))
plot(sf::st_geometry(mapSpain::esp_get_can_box()), add = TRUE)
}
Historical judicial districts (partidos judiciales) of Spain
Description
Judicial districts for the censuses of 1900, 1910, 1920 and 1930, built by
dissolving the municipalities of each census. cod_unit has 4 digits: the
province code and the district number (alphabetical order within the province,
the same in all censuses). Non-municipal territories (53xxx) are assigned to the
district of their province with which they share the longest boundary.
Usage
esp_get_pj_hist(
year,
epsg = 4258,
moveCAN = FALSE,
census_data = TRUE,
cache_dir = NULL,
update_cache = FALSE,
verbose = FALSE
)
Arguments
year |
Census year: 1900, 1910, 1920 or 1930. |
epsg |
EPSG code of the output (default 4258, ETRS89, as in mapSpain). |
moveCAN |
Position of the Canary Islands. |
census_data |
If |
cache_dir |
Cache directory. If |
update_cache |
If |
verbose |
If |
Value
An sf object with columns cod_unit, nom, n_mun and, optionally,
the census figures.
Examples
pj1910 <- esp_get_pj_hist(1910, cache_dir = tempdir())
Historical provinces of Spain for a census year
Description
Provinces built by dissolving the municipalities of the census, so they nest
exactly with esp_get_munic_hist(). Non-municipal territories (53xxx) are
assigned to the province that contains them.
Usage
esp_get_prov_hist(
year,
epsg = 4258,
moveCAN = FALSE,
census_data = TRUE,
cache_dir = NULL,
update_cache = FALSE,
verbose = FALSE
)
Arguments
year |
Census year, one of |
epsg |
EPSG code of the output (default 4258, ETRS89, as in mapSpain). |
moveCAN |
Position of the Canary Islands. |
census_data |
If |
cache_dir |
Cache directory. If |
update_cache |
If |
verbose |
If |
Value
An sf object with columns cod_unit (2-digit INE province code),
nom, n_mun and, optionally, the census figures; NULL (with a message)
if the geometries cannot be downloaded.
Examples
p1930 <- esp_get_prov_hist(1930, cache_dir = tempdir())
Cache directory of mapSpainHist
Description
The geometries are downloaded from Zenodo the first time they are needed and
stored in a cache directory. By default it is the user cache directory given by
tools::R_user_dir(). It can be changed for the session with
mhist_set_cache_dir() or with the cache_dir argument of the esp_get_*_hist()
functions.
Usage
mhist_cache_dir(cache_dir = NULL)
mhist_set_cache_dir(cache_dir)
Arguments
cache_dir |
Path of the cache directory. If |
Value
The path of the cache directory (invisibly for mhist_set_cache_dir()).
Examples
mhist_cache_dir()
old <- mhist_set_cache_dir(tempdir())
options(mapSpainHist.cache_dir = NULL)
Census editions available
Description
Census editions available
Usage
mhist_census_years()
Value
Integer vector with the census years covered by the package.
Examples
mhist_census_years()
Clear the cache of mapSpainHist
Description
Deletes the downloaded geometries, which will be downloaded again the next time they are needed.
Usage
mhist_clear_cache(cache_dir = NULL)
Arguments
cache_dir |
Path of the cache directory. If |
Value
TRUE invisibly if a file was deleted, FALSE otherwise.
Examples
mhist_clear_cache(tempdir())
Municipalities of each historical higher-level unit
Description
Correspondence between municipalities (cod_ine) and the units returned by
esp_get_prov_hist(), esp_get_pj_hist() and esp_get_circ_hist(). Useful to
aggregate municipal data. Non-municipal territories (53xxx) are included with
the unit they were assigned to.
Usage
unitats
Format
A data frame with columns:
- tipus
"prov","pj"(judicial district) or"circ"(electoral district).- any
Census year (prov, pj) or election year (circ: 1920, 1931, 1933, 1936).
- cod_ine
INE municipality code.
- cod_unit
Unit code (2 digits for provinces, 4 digits otherwise).