Learn R Programming

mapSpain (version 0.1.2)

esp_get_nuts: Get NUTS boundaries of Spain

Description

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

Usage

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:

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. See Details.

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) or

  • "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 Island close to Spain's mainland. Initial position can be adjusted using the vector of coordinates. See Note.

Value

A POLYGON/POINT object.

Details

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

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

See Also

esp_nuts.sf, esp_dict_region_code, esp_codelist, gisco_get.

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab