Description
The z22_data() function returns coordinates that are shifted 500m beyond the true cell centers (midpoints).
Cause
The package adds half the cell width to coordinates, assuming they represent southwest corners per INSPIRE guidelines. However, the official census CSV files already provide midpoint coordinates in the x_mp and y_mp columns ("mp" = "Mittelpunkt").
From the official Datensatzbeschreibung:
– x_mp_1km: Geografische Länge des Gitterzellmittelpunkts in ETRS89-LAEA Europe (EPSG: 3035)
– y_mp_1km: Geografische Breite des Gitterzellmittelpunkts in ETRS89-LAEA Europe (EPSG: 3035)
The INSPIRE corner coordinates are only encoded in the GITTER_ID string, not in the x/y columns.
Reproducible example
library(z22)
pop = z22_data("population", res = "1km", year = 2022, as = "df")
head(pop)
#> # A tibble: 6 × 3
#> cat_0 x y
#> <int> <dbl> <dbl>
#> 1 4 4338000 2690000
#> 2 11 4342000 2690000
#> ...
Compare with official CSV (Zensus2022_Bevoelkerungszahl_1km-Gitter.csv):
GITTER_ID_1km;x_mp_1km;y_mp_1km;Einwohner
CRS3035RES1000mN2689000E4337000;4337500;2689500;4
CRS3035RES1000mN2689000E4341000;4341500;2689500;11
The z22 coordinates are 500m higher than the official midpoints:
- Official: x=4337500, y=2689500
- z22: x=4338000, y=2690000
Suggested fix
Remove the shift_by_half() transformation since the source data already contains cell centers.
Description
The
z22_data()function returns coordinates that are shifted 500m beyond the true cell centers (midpoints).Cause
The package adds half the cell width to coordinates, assuming they represent southwest corners per INSPIRE guidelines. However, the official census CSV files already provide midpoint coordinates in the
x_mpandy_mpcolumns ("mp" = "Mittelpunkt").From the official Datensatzbeschreibung:
The INSPIRE corner coordinates are only encoded in the
GITTER_IDstring, not in the x/y columns.Reproducible example
Compare with official CSV (
Zensus2022_Bevoelkerungszahl_1km-Gitter.csv):The z22 coordinates are 500m higher than the official midpoints:
Suggested fix
Remove the
shift_by_half()transformation since the source data already contains cell centers.