Get spatial zones for the specified data version. Supports both v1 (2020-2021) and v2 (2022 onwards) data.
Usage
spod_get_zones(
zones = c("districts", "dist", "distr", "distritos", "municipalities", "muni",
"municip", "municipios", "lua", "large_urban_areas", "gau", "grandes_areas_urbanas"),
ver = NULL,
data_dir = spod_get_data_dir(),
quiet = FALSE
)
Arguments
- zones
The zones for which to download the data. Can be
"districts"
(or"dist"
,"distr"
, or the original Spanish"distritos"
) or"municipalities"
(or"muni"
,"municip"
, or the original Spanish"municipios"
) for both data versions. Additionaly, these can be"large_urban_areas"
(or"lua"
, or the original Spanish"grandes_areas_urbanas"
, or"gau"
) for v2 data (2022 onwards).- ver
Integer. Can be 1 or 2. The version of the data to use. v1 spans 2020-2021, v2 covers 2022 and onwards.
- data_dir
The directory where the data is stored. Defaults to the value returned by
spod_get_data_dir()
which returns the value of the environment variableSPANISH_OD_DATA_DIR
or a temporary directory if the variable is not set.- quiet
A
logical
value indicating whether to suppress messages. Default isFALSE
.
Value
An sf
object (Simple Feature collection).
The columns include (for both v1 (2020-2021) and v2 (2022 onwards) data:
- id
A character vector containing the unique identifier for each zone, to be matched with identifiers in the tabular data.
- geometry
A
MULTIPOLYGON
column containing the spatial geometry of each zone, stored as an sf object. The geometry is projected in the ETRS89 / UTM zone 30N coordinate reference system (CRS), with XY dimensions.
Additionally, for v2 (2022 onwards) data:
- name
A character vector with the name of the zone.
- population
A numeric vector representing the population of each zone (as of 2022).