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

esp_get_nuts(
  year = "2016",
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  resolution = "01",
  spatialtype = "RG",
  region = NULL,
  nuts_level = "all",
  moveCAN = TRUE
)

Arguments

year

Release year. One of "2003", "2006",`"2010", "2013", "2016" or "2021".

epsg

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

  • "4258": ETRS89

  • "4326": WGS84

  • "3035": ETRS89 / ETRS-LAEA

  • "3857": Pseudo-Mercator

cache

A logical whether to do caching. Default is TRUE.

update_cache

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

cache_dir

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

See Details on esp_get_nuts().

verbose

Display information. Useful for debugging, default is FALSE.

resolution

Resolution of the geospatial data. One of

  • "60": 1:60million

  • "20": 1:20million

  • "10": 1:10million

  • "03": 1:3million

  • "01": 1:1million

spatialtype

Type of geometry to be returned:

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

  • "LB": Labels - POINT object.

region

Optional. A vector of region names, NUTS or ISO codes (see esp_dict_region_code().

nuts_level

NUTS level. One of "0" (Country-level), "1", "2" or "3". See https://ec.europa.eu/eurostat/web/nuts/background.

moveCAN

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.

Source

GISCO API

Value

A POLYGON/POINT object.

Details

cache_dir = NULL (default) uses and creates /mapSpain directory in the temporary directory tempdir(). The directory can also be set via options with options(mapSpain_cache_dir = "path/to/dir") or options(gisco_cache_dir = "path/to/dir") (See giscoR::gisco_get())

Sometimes cached files may be corrupt. On that case, try redownloading the data using update_cache = TRUE.

Note

Please check the download and usage provisions on giscoR::gisco_attributions()

While moveCAN is useful for visualization, it would alter the actual geographical position of the Canary Islands. When using the output for spatial analysis or using tiles (esp_getTiles() or addProviderEspTiles()) this option should be set to FALSE in order to get the actual coordinates.

See also

Author

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

Examples

library(sf) pal <- hcl.colors(5, palette = "Lisbon") NUTS1 <- esp_get_nuts(nuts_level = 1, moveCAN = TRUE) plot(st_geometry(NUTS1), col = pal)
NUTS1_alt <- esp_get_nuts(nuts_level = 1, moveCAN = c(15, 0)) plot(st_geometry(NUTS1_alt), col = pal)
NUTS1_orig <- esp_get_nuts(nuts_level = 1, moveCAN = FALSE) plot(st_geometry(NUTS1_orig), col = pal)
AndOriental <- esp_get_nuts(region = c("Almeria", "Granada", "Jaen", "Malaga")) plot(st_geometry(AndOriental), col = pal)
RandomRegions <- esp_get_nuts(region = c("ES1", "ES300", "ES51")) plot(st_geometry(RandomRegions), col = pal)
MixingCodes <- esp_get_nuts(region = c("ES4", "ES-PV", "Valencia")) plot(st_geometry(MixingCodes), col = pal)