esp_get_nuts {mapSpain} | R Documentation |
Get NUTS of Spain as sf
POLYGON
or POINT
Description
Returns NUTS regions of Spain
as POLYGON
or POINT
at a specified scale, as provided by
GISCO
(Geographic Information System of the Commission, depending of Eurostat).
NUTS are provided at three different levels:
-
"0": Country level.
-
"1": Groups of autonomous communities.
-
"2": Autonomous communities (CCAA).
-
"3": Roughly matches the provinces, but providing specific individual objects for each major island.
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 of the file. One of |
epsg |
projection of the map: 4-digit EPSG code. One of:
|
cache |
A logical whether to do caching. Default is |
update_cache |
A logical whether to update cache. Default is |
cache_dir |
A path to a cache directory. See About caching. |
verbose |
Logical, displays information. Useful for debugging,
default is |
resolution |
Resolution of the geospatial data. One of
|
spatialtype |
Type of geometry to be returned:
|
region |
Optional. A vector of region names, NUTS or ISO codes
(see |
nuts_level |
NUTS level. One of |
moveCAN |
A logical |
Value
A sf
object specified by spatialtype
.
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.
Displacing the Canary Islands
While moveCAN
is useful for visualization, it would alter the actual
geographic position of the Canary Islands. When using the output for
spatial analysis or using tiles (e.g. with esp_getTiles()
or
addProviderEspTiles()
) this option should be set to FALSE
in order to
get the actual coordinates, instead of the modified ones. See also
esp_move_can()
for displacing stand-alone sf
objects.
Note
Please check the download and usage provisions on
giscoR::gisco_attributions()
Source
See Also
giscoR::gisco_get_nuts()
, esp_dict_region_code()
.
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_prov()
,
esp_get_simpl_prov()
Other nuts:
esp_nuts.sf
Examples
NUTS1 <- esp_get_nuts(nuts_level = 1, moveCAN = TRUE)
library(ggplot2)
ggplot(NUTS1) +
geom_sf() +
labs(
title = "NUTS1: Displacing Canary Islands",
caption = giscoR::gisco_attributions()
)
NUTS1_alt <- esp_get_nuts(nuts_level = 1, moveCAN = c(15, 0))
ggplot(NUTS1_alt) +
geom_sf() +
labs(
title = "NUTS1: Displacing Canary Islands",
subtitle = "to the right",
caption = giscoR::gisco_attributions()
)
NUTS1_orig <- esp_get_nuts(nuts_level = 1, moveCAN = FALSE)
ggplot(NUTS1_orig) +
geom_sf() +
labs(
title = "NUTS1",
subtitle = "Canary Islands on the true location",
caption = giscoR::gisco_attributions()
)
AndOriental <- esp_get_nuts(region = c(
"Almeria", "Granada",
"Jaen", "Malaga"
))
ggplot(AndOriental) +
geom_sf()
RandomRegions <- esp_get_nuts(region = c("ES1", "ES300", "ES51"))
ggplot(RandomRegions) +
geom_sf() +
labs(title = "Random Regions")
MixingCodes <- esp_get_nuts(region = c("ES4", "ES-PV", "Valencia"))
ggplot(MixingCodes) +
geom_sf() +
labs(title = "Mixing Codes")