Skip to content

Update location data for Census 2022#37

Merged
Nowosad merged 4 commits intoNowosad:masterfrom
jannes-m:update-census-2022
Jan 27, 2026
Merged

Update location data for Census 2022#37
Nowosad merged 4 commits intoNowosad:masterfrom
jannes-m:update-census-2022

Conversation

@jannes-m
Copy link
Copy Markdown
Contributor

@jannes-m jannes-m commented Jan 21, 2026

Summary

This PR updates the location/geomarketing datasets to use Census 2022 data (via the z22 package) instead of the bundled Census 2011 data.

Changes

  • Remove census_de: This dataset is no longer needed as Chapter 14 now uses the z22 package directly
  • Regenerate metro_names: Now detects 10 metropolitan areas (vs 8 with Census 2011)
    • Added: Hannover, Dresden
  • Regenerate shops: Updated OSM shop data for all 10 metros (~180k shops)
  • Update documentation: Removed census_de docs, updated metro_names/shops docs
  • Update data-raw script: Uses z22 package for data generation

Breaking Changes

  • census_de dataset is removed
  • Users should use the z22 package directly for German census data

Coordination

⚠️ This PR must be merged together with geocompx/geocompr#1175

The geocompr Chapter 14 refactoring depends on these updated datasets.

Test Plan

  • Verify metro_names has 10 entries
  • Verify shops sf object has geometry and ~180k rows
  • Run Chapter 14 of geocompr with updated spDataLarge

🤖 Generated with Claude Code

- Remove census_de dataset (Chapter 14 now uses z22 package directly)
- Regenerate metro_names using Census 2022 population data
  - Now detects 10 metropolitan areas (vs 8 with Census 2011)
  - Added: Hannover, Dresden
- Regenerate shops data for updated metro list (~180k shops)
- Update documentation to reflect changes
- Update data-raw script to use z22 package

Breaking change: census_de is removed. Users should use the z22
package directly for German census data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jannes and others added 2 commits January 21, 2026 12:39
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The z22 package now returns correct coordinates, see JsLth/z22#4.
Updated installation instruction to use GitHub version.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Nowosad
Copy link
Copy Markdown
Owner

Nowosad commented Jan 22, 2026

Hi @jannes-m -- thanks for the PR.

Two questions I have before merging:

  1. The shops.rda is now three times larger than before (4.5 MB vs 1.5 MB). Is this expected?
  2. Would it not be better (for future stability) to update the census_de object rather than depending on the external package?

- Bundle census data (pop, women, mean_age, hh_size) at 1km resolution
- Removes z22 runtime dependency from geocompr chapter
- Population, mean_age, hh_size from Census 2022; women from Census 2011
- z22 package still used during data preparation (data-raw script)
- Update documentation in R/location.R

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jannes-m
Copy link
Copy Markdown
Contributor Author

Updated approach based on feedback

After discussion, we've changed the approach to bundle census_de in spDataLarge instead of removing it. This addresses the concern about the external z22 dependency.

Changes in latest commits:

Regarding shops.rda size increase (1.5 MB → 4.5 MB):

  • Expected increase due to Census 2022 detecting 10 metros vs 8
  • Added Dresden (new metro) and Hannover (detected via Langenhagen)
  • Plus 4 years of OSM data growth (more shops mapped since 2022)
  • Old: ~104k shops → New: ~180k shops

Regarding z22 external dependency:

  • Now bundling census_de dataset in spDataLarge for stability
  • z22 is only used during data preparation (data-raw script), not at runtime
  • Chapter 14 shows z22 code (eval=FALSE) to document data source, but loads from spDataLarge for reproducibility

census_de dataset:

  • Columns: x, y, pop, women, mean_age, hh_size (1km resolution, EPSG:3035)
  • pop, mean_age, hh_size from Census 2022
  • women from Census 2011 (not available in 2022)
  • Size: ~1.1 MB

Ready for review!

@Nowosad Nowosad merged commit 8a72089 into Nowosad:master Jan 27, 2026
1 check passed
@Nowosad
Copy link
Copy Markdown
Owner

Nowosad commented Jan 27, 2026

Thanks @jannes-m -- I merged the pull request, fixed some urls, updated docs, and updated version (see d75b765).

@jannes-m
Copy link
Copy Markdown
Contributor Author

Awesome, thanks a lot @Nowosad!

@jannes-m jannes-m deleted the update-census-2022 branch January 27, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants