View source: R/gisco_get_units.R
| gisco_get_units | R Documentation |
Download individual shapefiles of units. Unlike gisco_get_countries(),
gisco_get_nuts() or gisco_get_urban_audit(), that downloads a full
dataset and applies filters, gisco_get_units() downloads a single
shapefile for each unit.
gisco_get_units(
id_giscoR = c("nuts", "countries", "urban_audit"),
unit = "ES4",
mode = c("sf", "df"),
year = "2016",
epsg = "4326",
cache = TRUE,
update_cache = FALSE,
cache_dir = NULL,
verbose = FALSE,
resolution = "20",
spatialtype = "RG"
)
id_giscoR |
Select the |
unit |
Unit ID to be downloaded. See Details. |
mode |
Controls the output of the function. Possible values are |
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: |
The function can return a data frame on mode = "df" or a sf
object on mode = "sf".
In order to see the available unit ids with the required
combination of spatialtype, year, first run the function on "df"
mode. Once that you get the data frame you can select the required ids
on the unit parameter.
On mode = "df" the only relevant parameters are spatialtype, year.
A sf object on mode = "sf" or a data frame on mode = "df".
You can set your cache_dir with gisco_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.
For a complete list of files available check gisco_db.
Country-level files would be renamed on your cache_dir
to avoid naming conflicts with NUTS-0 datasets.
Please check the download and usage provisions on gisco_attributions().
dieghernan, https://github.com/dieghernan/
https://gisco-services.ec.europa.eu/distribution/v2/
gisco_get_countries()
Other political:
gisco_bulk_download(),
gisco_get_coastallines(),
gisco_get_countries(),
gisco_get_lau(),
gisco_get_nuts(),
gisco_get_postalcodes(),
gisco_get_urban_audit()
cities <- gisco_get_units(
id_giscoR = "urban_audit",
mode = "df",
year = "2020"
)
VAL <- cities[grep("Valencia", cities$URAU_NAME), ]
# Order from big to small
VAL <- VAL[order(as.double(VAL$AREA_SQM), decreasing = TRUE), ]
VAL.sf <- gisco_get_units(
id_giscoR = "urban_audit",
year = "2020",
unit = VAL$URAU_CODE
)
# Provincia
Provincia <-
gisco_get_units(
id_giscoR = "nuts",
unit = c("ES523"),
resolution = "01"
)
# Reorder
VAL.sf$URAU_CATG <- factor(VAL.sf$URAU_CATG, levels = c("F", "K", "C"))
# Plot
library(ggplot2)
ggplot(Provincia) +
geom_sf(fill = "gray1") +
geom_sf(data = VAL.sf, aes(fill = URAU_CATG)) +
scale_fill_viridis_d() +
labs(
title = "Valencia",
subtitle = "Urban Audit",
fill = "Urban Audit\ncategory"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.