pycensus.census.countries.germany.destatis.loader¶
Loader for Germany Destatis GENESIS-Online census data.
Technical aspects
Real geography (:mod:pycensus.germany.geography, GISCO NUTS) is always
available. Real population data requires a registered GENESIS-Online
account (see :mod:pycensus.germany.api module docstring). When no
credentials are configured, :func:load raises
:class:pycensus.germany.api.GenesisCredentialsError (a clear,
specific error, not a silent fabricated-data fallback) so callers can
catch it and fall back to a non-census source, e.g.
:mod:pycensus.census.worldwide.worldpop, in the meantime.
Verified live 2026-08-21: the token in api_keys.json DOES
authenticate against the real (corrected) GENESIS-Online host and DOES
retrieve real data -- see :mod:pycensus.germany.api and
:mod:pycensus.germany.destatis.README for the fix (host without
"www-" prefix, credentials as HTTP headers not body fields) and the
live-verified numbers. Nation and state population are wired below,
parsed from real data/table responses (a semicolon-delimited flat
text format, not JSON rows) for tables 12411-0001/12411-0010.
District (12411-0015) is now wired too -- verified live 2026-08-22.
Its rows are keyed by real 5-digit AGS codes, which have no fixed
arithmetic relationship to GISCO's NUTS3 GEOID\ s; a real
name-matched crosswalk (:mod:pycensus.census.countries.germany.destatis.crosswalk)
resolves this. See that module's docstring for the full match-rate and
population cross-check results (400/400 GENESIS district rows matched,
6 real districts spanning 6 different states independently
cross-checked against their real published Zensus 2022 populations).
Municipality (Gemeinde) is wired too -- verified live 2026-08-22, but
from a different real source than nation/state/district: GENESIS-
Online's public catalogue has no Gemeinde-level table under statistic
12411 (confirmed by exhausting catalogue/tables2statistic and
find/find search), so population comes from Eurostat/GISCO's LAU
dataset instead (:func:pycensus.census.countries.germany.geography.municipality_population),
which already carries a real population figure (POP_2021) alongside
each boundary. No GENESIS account is required for this level. GISCO's
LAU_ID for Germany is literally the 8-digit AGS code (verified
against Flensburg/Kiel/Munich/Stuttgart/Berlin/Hamburg), so no
name-matching crosswalk is needed, unlike district. Sum-to-parent
cross-check: Landkreis Starnberg's 15 real LAU municipalities summed to
136,610 (2021 vintage) vs. GENESIS' 138,488 (31.12.2022) for the same
Kreis -- a +1.37% change over ~1.5 years, consistent with the growth
rates already verified for other districts.
load(aoi=None, regions=None, level='state', year='latest', api_key=None, cache_dir=None, cache=True, data_dir=None)
¶
Load Germany census data for one or more regions/an AOI.
Raises:
| Type | Description |
|---|---|
GenesisCredentialsError
|
If no real GENESIS-Online account is
configured in |
ValueError
|
If neither |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi
|
Area of interest (GeoDataFrame). |
None
|
|
regions
|
State codes (instead of |
None
|
|
level
|
Geography level. |
'state'
|
|
year
|
Year or |
'latest'
|
|
api_key
|
GENESIS token. |
None
|
|
cache_dir
|
Cache folder; |
None
|
|
cache
|
Use the cached result. |
True
|
|
data_dir
|
Folder of the raw downloads; |
None
|
Returns:
| Type | Description |
|---|---|
|
GeoDataFrame of the level with the census columns. |
download_census_data(data_type='aggregated', level='state', regions=None, year=2022, data_dir=None, cache_dir=None, overwrite=False)
¶
Download real Germany geography, and real census data if credentials are configured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_type
|
|
'aggregated'
|