z22_data | R Documentation |
Retrieve the values and coordinates of gridded features from the censuses 2011 and 2022.
When we are talking about a
feature, we talk about an indicator aggregated to grid cells, e.g., age or the number of dwellings.
category, we talk about the discrete classifications of features, e.g., ages 10 to 19, 20 to 20, 30 to 39, etc.
Both feature and category have to be provided to uniquely identify a dataset.
z22_data(
feature,
categories = NULL,
year = 2022,
res = "1km",
all_cells = FALSE,
normalize = FALSE,
rasterize = FALSE,
as_sf = FALSE,
update_cache = FALSE
)
feature |
A grid feature. See |
categories |
One or multiple feature categories. See
|
year |
Census year. Currently, only 2011 and 2022 are available. Defaults to 2022. |
res |
Resolution of the grid dataset. Can be |
all_cells |
If |
normalize |
If |
rasterize |
If |
as_sf |
If |
update_cache |
By default, both functions cache attribute files for
the remainder of the R session. They are downloaded to a temporary directory
and - if the file to download already exists - are recovered from the cache.
In other words, when rerunning the same request multiple times, the
subsequent calls should be much faster. If |
Half of the grids cell width is added to each coordinate in the dataset internally. According to the INSPIRE guidelines, coordinates always represent the South-west of the grid cells. Centroids represent the geographic location of grid cells better which is why they are used.
By default, data are downloaded from the
z22data data repository which
stores all pre-processed data. You can download this repository and use
it offline or use an entirely different repository by setting
options(z22.data_repo = "path/to/z22data")
.
A tibble, SpatRasterDataset
or
sf
tibble depending on the rasterize
and as_sf
arguments.
If a tibble is returned each category in categories
is stored in
a column. If a SpatRasterDataset
is returned, each category is a
named layer.
# Get gridded population
pop <- z22_data("population", res = "10km", rasterize = TRUE)
terra::plot(pop$cat_0)
# Get data about the number of people born in a EU27 country
z22_data("birth_country", categories = 21, res = "1km")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.