View source: R/esp-get-munic.R
| esp_get_munic | R Documentation |
This dataset shows boundaries of municipalities in Spain.
esp_get_munic(
year = 2024,
epsg = 4258,
cache = deprecated(),
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE,
region = NULL,
munic = NULL,
moveCAN = TRUE,
ext = "gpkg"
)
year |
year character string or number. Release year of the file. See
|
epsg |
character string or number. Projection of the map: 4-digit EPSG code. One of:
|
cache |
|
update_cache |
logical. Should the cached file be refreshed? Default
is |
cache_dir |
character string. A path to a cache directory. See
Caching strategies section in |
verbose |
logical. If |
region |
Optional. A vector of region names, NUTS or ISO codes
(see |
munic |
character string. A name or |
moveCAN |
A logical |
ext |
character. Extension of the file (default |
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"
(see esp_codelist).
When calling a higher level (province, CCAA or NUTS1), all the municipalities of that level will be added.
A sf object.
Please check the download and usage provisions on gisco_attributions().
https://gisco-services.ec.europa.eu/distribution/v2/.
Copyright: https://ec.europa.eu/eurostat/web/gisco/geodata/statistical-units.
giscoR::gisco_get_lau(), giscoR::gisco_get_communes().
Other datasets representing political borders:
esp_get_capimun(),
esp_get_ccaa(),
esp_get_ccaa_siane(),
esp_get_comarca(),
esp_get_countries_siane(),
esp_get_gridmap,
esp_get_munic_siane(),
esp_get_nuts(),
esp_get_prov(),
esp_get_prov_siane(),
esp_get_simpl,
esp_get_spain(),
esp_get_spain_siane(),
esp_siane_bulk_download()
Datasets representing municipalities:
esp_get_capimun(),
esp_get_munic_siane()
Datasets provided by GISCO:
esp_get_ccaa(),
esp_get_nuts(),
esp_get_prov(),
esp_get_spain()
# The Spanish Lapland:
# https://en.wikipedia.org/wiki/Celtiberian_Range
# Get munics
spanish_laplad <- esp_get_munic(
year = 2023,
region = c(
"Cuenca", "Teruel",
"Zaragoza", "Guadalajara",
"Soria", "Burgos",
"La Rioja"
)
)
breaks <- sort(c(0, 5, 10, 50, 100, 200, 500, 1000, Inf))
spanish_laplad$dens_breaks <- cut(spanish_laplad$POP_DENS_2023, breaks,
dig.lab = 20
)
cut_labs <- prettyNum(breaks, big.mark = " ")[-1]
cut_labs[length(breaks)] <- "> 1000"
library(ggplot2)
ggplot(spanish_laplad) +
geom_sf(aes(fill = dens_breaks), color = "grey30", linewidth = 0.1) +
scale_fill_manual(
values = hcl.colors(length(breaks) - 1, "Spectral"), na.value = "black",
name = "people per sq. kilometer",
labels = cut_labs,
guide = guide_legend(
direction = "horizontal",
nrow = 1
)
) +
theme_void() +
labs(
title = "The Spanish Lapland",
caption = giscoR::gisco_attributions()
) +
theme(
text = element_text(colour = "white"),
plot.background = element_rect(fill = "grey2"),
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5, face = "bold"),
plot.caption = element_text(
color = "grey60", hjust = 0.5, vjust = 0,
margin = margin(t = 5, b = 10)
),
legend.position = "bottom",
legend.title.position = "top",
legend.text.position = "bottom",
legend.key.height = unit(0.5, "lines"),
legend.key.width = unit(1, "lines")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.