View source: R/esp_get_comarca.R
esp_get_comarca | R Documentation |
sf
POLYGON
Returns 'comarcas' of Spain as sf
POLYGON
objects, as provided by the
INE (Instituto Nacional de Estadistica).
esp_get_comarca(
region = NULL,
comarca = NULL,
moveCAN = TRUE,
epsg = "4258",
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE
)
region |
A vector of names and/or codes for provinces or |
comarca |
A name or |
moveCAN |
A logical |
epsg |
projection of the map: 4-digit EPSG code. One of:
|
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 |
'Comarcas' (English equivalent: district, county, area or zone) does not always have a formal legal status. They correspond mainly to natural areas (valleys, river basins etc.) or even to historical regions or ancient kingdoms.
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, Autonomous Community or NUTS1), all the comarcas of that level would be added.
The use of the information contained on the INE website may be carried out by users or re-use agents, at their own risk, and they will be the sole liable parties in the case of having to answer to third parties due to damages arising from such use.
A sf
polygon object.
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.
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.
INE: PC_Axis files.
Other political:
esp_codelist
,
esp_get_can_box()
,
esp_get_capimun()
,
esp_get_ccaa()
,
esp_get_country()
,
esp_get_gridmap
,
esp_get_munic()
,
esp_get_nuts()
,
esp_get_prov()
,
esp_get_simpl_prov()
comarcas <- esp_get_comarca(moveCAN = FALSE)
library(ggplot2)
ggplot(comarcas) +
geom_sf()
# Comarcas of Castille and Leon
comarcas_cyl <- esp_get_comarca("Castilla y Leon")
ggplot(comarcas_cyl) +
geom_sf(aes(fill = ine.prov.name)) +
labs(fill = "Province")
# Comarcas with Mountains or Alt(o,a) in the name
comarcas_alto <- esp_get_comarca(
comarca = "MontaƱa|Monte|Sierra|Alt",
epsg = 3857
)
ggplot(comarcas_alto) +
geom_sf(aes(fill = ine.ccaa.name)) +
geom_sf_text(aes(label = name), check_overlap = TRUE) +
labs(fill = "CCAA")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.