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

esp_get_prov uses GISCO (Eurostat) as source

esp_get_prov_siane use 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_prov(prov = NULL, ...)

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

Arguments

prov

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

...

Arguments passed on to esp_get_nuts

spatialtype

Type of geometry to be returned:

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

  • "LB": Labels - POINT object.

year

Release year. See esp_get_nuts() for esp_get_prov and Details for esp_get_prov_siane

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 polygon. Values available are "3", "6.5" or "10".

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.

rawcols

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

Source

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

Value

A POLYGON/POINT object.

Details

When using prov you can use and mix names and NUTS codes (levels 1, 2 or 3), ISO codes (corresponding to level 2 or 3) or cpro.

Ceuta and Melilla are considered as provinces on this dataset.

When calling a superior level (Autonomous Community or NUTS1) , all the provinces of that level would be added.

On esp_get_prov_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

Author

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

Examples

library(sf) # Random Provinces Random <- esp_get_prov(prov = c( "Zamora", "Palencia", "ES-GR", "ES521", "01" )) plot(st_geometry(Random), col = hcl.colors(6))
# All Provinces of a Zone plus an addition # Low resolution (20M) Mix <- esp_get_prov( prov = c( "Noroeste", "Castilla y Leon", "La Rioja" ), resolution = "20" ) plot( Mix[, "nuts1.code"], pal = hcl.colors(3), key.pos = NULL, main = NULL, border = "white" )
# ISO codes available allprovs <- esp_get_prov() library(tmap) tmap_style("cobalt")
#> tmap style set to "cobalt"
#> other available styles are: "white", "gray", "natural", "col_blind", "albatross", "beaver", "bw", "classic", "watercolor"
tm_shape(allprovs, point.per = "feature") + tm_polygons() + tm_text("iso2.prov.code", remove.overlap = TRUE)
#> tmap options successfully reset