| 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,
as = c("df", "sf", "raster"),
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 |
as |
Specifies the output class. Must be one of |
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 |
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").
Census data are protected using the cell-key method. As a consequence,
cell values are confidentialized by perturbation and often do not
represent true values. The mean absolute deviation for counts is
below 1. 65 % of counts have a maximum perturbation of 1, 20 %
of 3 or more and 10 % of 4 or more (Enderle and Kleber 2024).
Population totals (such as "population", or "dwellings")
add perturbation after adding up subtotals to preserve accuracy.
Hence, the sum of subtotals can deviate from the totals, e.g., the
sum of each category in "household_size_group" and the value
of "households" can be different. The normalize argument
takes this into account and computes shares based on the sum of
subtotals instead as suggested by Enderle and Kleber (2024).
A tibble, SpatRaster or
sf tibble depending on the as argument.
If a tibble is returned each category in categories is stored in
a column. If a SpatRaster is returned, each category is a
named layer.
Enderle, T., Kleber, B., 2024. Geheimhaltung mit der Cell-Key-Methode im Zensus 2022. WISTA Wirtschaft und Statistik 6/2024, 83-91.
# Get gridded population
pop <- z22_data("population", res = "10km", as = "raster")
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.