Get the location of the political powers for each municipality (possibly the center of the municipality).

Note that this differs of the centroid of the boundaries of the municipallity, returned by esp_get_munic().

esp_get_capimun(
  year = Sys.Date(),
  epsg = "4258",
  cache = TRUE,
  update_cache = FALSE,
  cache_dir = NULL,
  verbose = FALSE,
  region = NULL,
  munic = NULL,
  moveCAN = TRUE,
  rawcols = FALSE
)

Arguments

year

Release year. See Details for years available.

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.

region

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

munic

A name or regex expression with the names of the required municipalities. NULL would not produce any filtering.

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 POINT object.

Details

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.

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

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

Note

While moveCAN is useful for visualization, it would alter the actual geographical position of the Canary Islands.

See also

Author

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

Examples

# \dontrun{ # This code compares centroid of municipalities against esp_get_capimun # It also download tiles, make sure you are online library(sf) # Get shape area <- esp_get_munic_siane(munic = "Valladolid", epsg = 3857) # Area in km2 print(paste0(round(as.double(st_area(area)) / 1000000, 2), " km2"))
#> [1] "353.42 km2"
# Extract centroid centroid <- st_centroid(area)
#> Warning: st_centroid assumes attributes are constant over geometries of x
# Compare with capimun capimun <- esp_get_capimun(munic = "Valladolid", epsg = 3857) # Get a tile to check tile <- esp_getTiles(area) # Check on plot library(tmap) tm_shape(tile, raster.downsample = FALSE) + tm_rgb() + tm_shape(area) + tm_borders(col = "grey40") + tm_shape(centroid) + tm_symbols(col = "red", alpha = 0.4, shape = 19) + tm_shape(capimun) + tm_symbols(col = "blue", alpha = 0.4, shape = 19)
# Blue dot is located onto the actual city while red dot is located # in the centroid of the boundaries # }