Loads a simple feature (sf) object containing the autonomous communities boundaries of Spain.

esp_get_ccaa uses GISCO (Eurostat) as source

esp_get_ccaa_siane uses CartoBase ANE as source, provided by Instituto Geografico Nacional (IGN), http://www.ign.es/web/ign/portal.

Years available are 2005 up to today.

esp_get_ccaa(ccaa = NULL, ...)

  ccaa = NULL,
  year = Sys.Date(),
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  resolution = "3",
  moveCAN = TRUE,
  rawcols = FALSE



A vector of names and/or codes for autonomous communities or NULL to get all the autonomous communities. See Details.


Arguments passed on to esp_get_nuts


Type of geometry to be returned:

  • "RG": Regions - MULTIPOLYGON/POLYGON object.

  • "LB": Labels - POINT object.


Release year. See esp_get_nuts() for esp_get_ccaa and Details for esp_get_ccaa_siane


projection of the map: 4-digit EPSG code. One of:

  • "4258": ETRS89

  • "4326": WGS84

  • "3035": ETRS89 / ETRS-LAEA

  • "3857": Pseudo-Mercator


A logical whether to do caching. Default is TRUE.


A logical whether to update cache. Default is FALSE. When set to TRUE it would force a fresh download of the source .geojson file.


A path to a cache directory. The directory can also be set globally with:

See Details on esp_get_nuts().


Display information. Useful for debugging, default is FALSE.


Resolution of the polygon. Values available are "3", "6.5" or "10".


A logical TRUE/FALSE or a vector of coordinates c(lat, lon). It places the Canary Islands close to Spain's mainland. Initial position can be adjusted using the vector of coordinates.


Logical. Setting this to TRUE would add the raw columns of the dataset provided by IGN.


IGN data via a custom CDN (see https://github.com/rOpenSpain/mapSpain/tree/sianedata.




When using ccaa you can use and mix names and NUTS codes (levels 1 or 2), ISO codes (corresponding to level 2) or codauto. Ceuta and Melilla are considered as Autonomous Communities on this dataset.

When calling a NUTS1 level, all the Autonomous Communities of that level would be added.

On esp_get_ccaa_siane, year could be passed as a single year ("YYYY" format, as end of year) or as a specific date ("YYYY-MM-DD" format). Historical information starts as of 2005.

See also


dieghernan, https://github.com/dieghernan/


# Random CCAA Random <- esp_get_ccaa(ccaa = c( "Euskadi", "Catalunya", "ES-EX", "Canarias", "ES52", "01" )) library(tmap) tm_shape(Random) + tm_polygons(col = "codauto", legend.show = FALSE) + tm_shape(Random, point.per = "feature") + tm_text("codauto", auto.placement = TRUE, shadow = TRUE )
# All CCAA of a Zone plus an addition Mix <- esp_get_ccaa( ccaa = c("La Rioja", "Noroeste"), resolution = "20" ) # Base plot plot( Mix[, "nuts1.code"], pal = hcl.colors(2), key.pos = NULL, main = NULL, border = "white" )
# Combine with giscoR to get countries # \donttest{ library(giscoR) library(sf) res <- 20 # Set same resoluion europe <- gisco_get_countries(resolution = res) ccaa <- esp_get_ccaa(moveCAN = FALSE, resolution = res) # Transform to same CRS europe <- st_transform(europe, 3035) ccaa <- st_transform(ccaa, 3035) tm_shape(europe, bbox = c(23, 14, 74, 55) * 10e4) + tm_polygons("#DFDFDF", border.col = "#656565") + tm_shape(ccaa) + tm_polygons("#FDFBEA", border.col = "#656565") + tm_layout(bg.color = "#C7E7FB")
# }