Skip to content

Commit e4c7d29

Browse files
jannesclaude
andcommitted
Remove z22 coordinate offset (fixed upstream)
The z22 package now returns correct coordinates, see JsLth/z22#4. Also add GitHub installation instruction for z22. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bd8a415 commit e4c7d29

3 files changed

Lines changed: 3 additions & 12 deletions

File tree

14-location.Rmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ library(z22)
1818
library(spDataLarge)
1919
```
2020

21-
We use the **z22** package to access gridded German census data from 2022.
21+
We use the **z22** package [@R-z22] to access gridded German census data from 2022.
22+
Install it from GitHub with `remotes::install_github("JsLth/z22")`.
2223
Census data on shops (`shops`) and metropolitan names (`metro_names`) are available from **spDataLarge**.
2324

2425
## Introduction
@@ -101,9 +102,6 @@ input_tidy = pop |>
101102
# Filter out missing values (coded as -1)
102103
input_tidy = input_tidy |>
103104
mutate(across(c(pop, women, mean_age, hh_size), ~ifelse(.x < 0, NA, .x)))
104-
# Correct z22 coordinate offset (z22 adds 500m to already-midpoint coordinates)
105-
input_tidy = input_tidy |>
106-
mutate(x = x - 500, y = y - 500)
107105
```
108106

109107
```{r census-desc, echo=FALSE}

_14-ex.Rmd

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Note that the 100 m data is much larger and may take some time to download.
2424
pop_1km = z22_data("population", res = "1km", year = 2022, as = "df")
2525
pop_1km = pop_1km |>
2626
rename(pop = cat_0) |>
27-
mutate(pop = ifelse(pop < 0, NA, pop)) |>
28-
mutate(x = x - 500, y = y - 500) # Correct z22 coordinate offset
27+
mutate(pop = ifelse(pop < 0, NA, pop))
2928
inh_coarse = terra::rast(pop_1km, type = "xyz", crs = "EPSG:3035")
3029
3130
# Fine inhabitant raster (100 m resolution)
@@ -76,9 +75,6 @@ input_tidy = pop |>
7675
left_join(hh_size, by = c("x", "y")) |>
7776
select(x, y, pop, women, mean_age, hh_size) |>
7877
mutate(across(c(pop, women, mean_age, hh_size), ~ifelse(.x < 0, NA, .x)))
79-
# Correct z22 coordinate offset (z22 adds 500m to already-midpoint coordinates)
80-
input_tidy = input_tidy |>
81-
mutate(x = x - 500, y = y - 500)
8278
input_ras = terra::rast(input_tidy, type = "xyz", crs = "EPSG:3035")
8379
8480
# attach further necessary data

code/14-location-figures.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ input_tidy = pop |>
6161
# Filter out missing values (coded as -1)
6262
input_tidy = input_tidy |>
6363
mutate(across(c(pop, women, mean_age, hh_size), ~ifelse(.x < 0, NA, .x)))
64-
# Correct z22 coordinate offset (z22 adds 500m to already-midpoint coordinates)
65-
input_tidy = input_tidy |>
66-
mutate(x = x - 500, y = y - 500)
6764
input_ras = terra::rast(input_tidy, type = "xyz", crs = "EPSG:3035")
6865

6966
# reproject German outline

0 commit comments

Comments
 (0)