
Get a simplified map of provinces and autonomous communities of Spain
Source:R/esp_get_simplified.R
esp_get_simplified.RdLoads a simplified map (sf object) with the boundaries of the
provinces or autonomous communities of Spain, as provided by the INE
(Instituto Nacional de Estadistica).
Usage
esp_get_simpl_prov(
prov = NULL,
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
esp_get_simpl_ccaa(
ccaa = NULL,
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)Arguments
- prov
A vector of names and/or codes for provinces or
NULLto get all the provinces. See Details.- update_cache
A logical whether to update cache. Default is
FALSE. When set toTRUEit would force a fresh download of the source file.- cache_dir
A path to a cache directory. See About caching.
- verbose
Logical, displays information. Useful for debugging, default is
FALSE.- ccaa
A vector of names and/or codes for autonomous communities or
NULLto get all the autonomous communities. See Details.
Value
A sf POLYGON object.
Details
Results are provided without CRS, as provided on source.
You can use and mix names, ISO codes, "codauto"/"cpro" codes (see
esp_codelist) and NUTS codes of different levels.
When using a code corresponding of a higher level (e.g.
esp_get_simpl_prov("Andalucia")) all the corresponding units of that level
are provided (in this case , all the provinces of Andalusia).
About caching
You can set your cache_dir with esp_set_cache_dir().
Sometimes cached files may be corrupt. On that case, try re-downloading
the data setting update_cache = TRUE.
If you experience any problem on download, try to download the
corresponding .geojson file by any other method and save it on your
cache_dir. Use the option verbose = TRUE for debugging the API query.
See also
esp_get_hex_prov(), esp_get_hex_ccaa()
Other political:
esp_codelist,
esp_get_can_box(),
esp_get_capimun(),
esp_get_ccaa(),
esp_get_comarca(),
esp_get_country(),
esp_get_gridmap,
esp_get_munic(),
esp_get_nuts(),
esp_get_prov()
Examples
# \donttest{
prov_simp <- esp_get_simpl_prov()
library(ggplot2)
ggplot(prov_simp) +
geom_sf(aes(fill = ine.ccaa.name)) +
labs(fill = "CCAA")
# Provs of Single CCAA
and_simple <- esp_get_simpl_prov("Andalucia")
ggplot(and_simple) +
geom_sf()
# CCAAs
ccaa_simp <- esp_get_simpl_ccaa()
ggplot(ccaa_simp) +
geom_sf() +
geom_sf_text(aes(label = ine.ccaa.name), check_overlap = TRUE)
# }