pycensus.census.countries.germany.destatis.crosswalk¶
Real AGS-to-NUTS3 crosswalk for Germany's 400/401 Kreise.
Technical aspects
Destatis' GENESIS-Online publishes district population (table
12411-0015) keyed by real 5-digit AGS (Amtlicher Gemeindeschluessel)
codes -- confirmed live 2026-08-22: each data line's first
semicolon-delimited field is a literal AGS code (e.g. "09162"), the
second is the district's real German name including its Kreistyp suffix
(", Landkreis" / ", kreisfreie Stadt"), and the last is the
population value -- e.g. "09162;München, kreisfreie Stadt;1490516".
GISCO's NUTS3 boundaries (:mod:pycensus.census.countries.germany.geography)
are keyed by an entirely different code, the NUTS3 ID (e.g.
"DE212"), with no fixed arithmetic relationship to AGS. GISCO's
NUTS_NAME property is, however, the same real district name (in a
similar but not identical format -- GISCO sometimes abbreviates, e.g.
"a. d." for "an der", "i." for "im"/"in", and uses
"Stadtkreis" where GENESIS says "kreisfreie Stadt" for
Baden-Wuerttemberg specifically).
This module builds the crosswalk by real name-matching: strip each
name's Kreistyp suffix into a (core_name, type) pair (type is
"stadt" or "land", used only to disambiguate the ~20 real cases
where a kreisfreie Stadt and its surrounding Landkreis share the same
core name, e.g. Munich city vs. Munich district), normalize accents and
abbreviations, and match. An exact core-name match (after
normalization) resolves most districts; a small number of GISCO's own
abbreviated spellings ("Neumarkt i. d. OPf." for GENESIS' "Neumarkt
in der Oberpfalz") need a fuzzy (difflib.SequenceMatcher) fallback,
restricted to the same Kreistyp when known -- verified live 2026-08-22:
of Germany's 400 real GENESIS district rows, 395 match by exact
normalized core name and 5 by fuzzy match (all >=0.75 ratio, four of
them >=0.96), for a 100% match rate against GENESIS' 400 rows, with
zero GISCO NUTS3 codes claimed twice.
Real, documented discrepancy: GISCO's NUTS 2021 vintage has 401 German
NUTS3 features, but GENESIS' table 12411-0015 (31.12.2022 Stichtag) has
only 400 rows. The one unmatched GISCO code is DEG0N
("Eisenach, Kreisfreie Stadt") -- Eisenach (Thuringia) merged into
the surrounding Wartburgkreis on 2021-07-01, a real, documented
territorial reform; GENESIS' 2022 data already reflects the merger
(Wartburkreis, AGS 16063, includes former Eisenach's population), while
GISCO's NUTS 2021 boundary vintage still lists Eisenach as a separate
unit. This is a real administrative-geography quirk, not a matching
bug -- see :func:build_crosswalk's docstring for the live-verified
population sum this produces.
Live population cross-checks (2026-08-22), GENESIS 31.12.2022 vs. each district's real, independently published Zensus 2022 (2022-05-15 reference date) population -- a ~7.5-month gap in which modest growth is expected and observed in every case: - Muenchen (kreisfreie Stadt, AGS 09162 -> DE212): GENESIS 1,490,516; already independently verified in an earlier session against Destatis' own published 31.12.2022 figure (exact match). - Stuttgart (AGS 08111 -> DE111): GENESIS 612,041 vs. Zensus 2022 610,459 (city's own published census-day count, source: stuttgart.de) -- +0.26% over 7.5 months. - Koeln (AGS 05315 -> DE313): GENESIS 1,021,253 vs. Zensus 2022 1,017,355 (Statistisches Bundesamt/Land NRW press coverage) -- +0.38%. - Hamburg (AGS 02000 -> DE600): GENESIS 1,832,675 vs. Zensus 2022 ~1,811,343 (Statistik Nord: 1,875,180 pre-census minus a published -63,837 correction) -- +1.18%. - Berlin (AGS 11000 -> DE300): GENESIS 3,632,853 vs. Zensus 2022 3,596,999 (Amt fuer Statistik Berlin-Brandenburg) -- +1.00%. - Leipzig, kreisfreie Stadt (AGS 14713 -> DED51): GENESIS 603,578 vs. Zensus 2022 598,899 (Stadt Leipzig press release) -- +0.78%. All six real, independent cross-checks land within the expected small positive range for 7.5 months of population growth after the Zensus 2022 count -- strong evidence the crosswalk pairs the correct AGS code with the correct NUTS3 district, not just a plausible-looking number.
match_districts(ags_rows, nuts_names, fuzzy_threshold=0.75)
¶
Match GENESIS AGS district rows to GISCO NUTS3 codes by real name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ags_rows
|
List[Tuple[str, str, int]]
|
|
required |
nuts_names
|
Dict[str, str]
|
|
required |
fuzzy_threshold
|
float
|
Minimum |
0.75
|
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
|
List[Tuple[str, str, int]]
|
|
Tuple[Dict[str, str], List[Tuple[str, str, int]]]
|
confidence (no NUTS3 code is claimed by more than one AGS code); |
Tuple[Dict[str, str], List[Tuple[str, str, int]]]
|
|
Tuple[Dict[str, str], List[Tuple[str, str, int]]]
|
rows that could not be matched above |
Tuple[Dict[str, str], List[Tuple[str, str, int]]]
|
caller to report rather than silently drop. |