United Kingdom (GB) build pipeline
Self-contained — runs entirely from this repo. All paths are relative to this
scripts/ folder; sources/ and data/ are siblings under datasets/gb/ and are
gitignored (regenerable).
Restored 2026-08-25. These four scripts previously lived at repo root as uk/ and
were deleted in commit 35a9565 ("Remove uk/ folder") with no reason recorded; the built
dataset survived only as an untracked local copy. Recovered from git history (commit
1c247b5) and re-verified end to end against freshly downloaded sources — same row count,
same coverage stats as the original build. Relocated here to match the current
datasets/{cc}/ convention (the old uk/ layout predates it).
Run order
python3 parse_codepoint.py # 1. OS Code-Point Open -> ../data/gb_base.csv (BNG -> WGS84)
python3 enrich_uk.py # 2. join ONS name lookups -> ../data/gb.csv
python3 fill_place_name.py # 3. nearest GeoNames town -> place_name (in place)
python3 data_integrity_checker.py # 4. gate; writes ../data/consolidated_stats.json + sample
No fetch_source.py / package.py / publish_r2.py yet (unlike fr/sg) — sources are
currently fetched by hand into ../sources/ and there is no packaging or R2-publish step.
That is the gap left to close before this matches the fr/sg convention fully.
Inputs (../sources/, not committed)
| File | From | Notes |
|---|---|---|
../../../codepo_gb/Data/CSV/*.csv (120 files) | OS Code-Point Open | read directly, not copied into sources/ — see parse_codepoint.py |
ons_lad.csv | ONS — Local Authority Districts (April 2025) Names and Codes in the UK (V2) | columns LAD25CD/LAD25NM |
ons_county.csv | ONS — Counties (December 2025) Names and Codes in EN | columns CTY25CD/CTY25NM |
ons_ward_2022.csv | ONS — Wards (December 2022) Names and Codes in the UK | |
ons_ward_2023.csv | ONS — Wards (December 2023) Names and Codes in the UK | |
ons_ward.csv | ONS — Wards (May 2024) Names and Codes in the UK | "base" vintage |
ons_ward_2025.csv | ONS — Wards (May 2025) Names and Codes in the UK | |
GB.txt / GB.zip | GeoNames GB export | https://download.geonames.org/export/dump/GB.zip |
Ward vintages are unioned (newest wins on code collisions) so boundary-change drift in
Code-Point Open's ward codes still resolves — see enrich_uk.py::load_wards().
ONS files carry a UTF-8 BOM as downloaded — strip it before running enrich_uk.py,
which opens them as plain utf-8 and would otherwise get LAD25CD etc. as the first
column name and silently fail every lookup on that column.
Source and licence
Three sources, all open, all commercial-resale-permitted, none is OSM/Nominatim — this build does not touch the ODbL/Nominatim gate that blocks KWT/SGP/JEY coordinate builds.
| Source | Licence | Confirmed from |
|---|---|---|
| OS Code-Point Open | OGL v3.0 | codepo_gb/Doc/licence.txt — the licence file shipped inside the actual download, not a web claim |
| ONS Open Geography (LAD/Ward/County lookups) | OGL v3.0 | ons.gov.uk/methodology/geography/licences |
| GeoNames GB | CC BY 4.0 | geonames.org/export |
See ../.licensing-notes.md for the full attribution text and the compound-attribution
correction (OS's licence.txt names three copyright holders — OS, Royal Mail, and
National Statistics — not two; an earlier draft README here missed Royal Mail).
Verification (2026-08-25)
- 1,747,841 rows — matches the original (pre-deletion) build exactly.
admin_name2/admin_name3(district/ward): 99.9% fill — matches original.admin_county_name(two-tier England county): 31.9% fill — matches original.place_name: 100.0% fill via GeoNames nearest-place join.- Integrity check: PASS, 0 duplicate postal codes, 865 rows with no coordinate (OS positional-quality flag 90) — matches original.
Known characteristics (not defects)
- Great Britain only — Code-Point Open does not cover Northern Ireland.
- 865 postcodes (positional quality 90) have blank
latitude/longitude/place_name. admin_county_name/admin_county_codeare populated only for two-tier England counties (31.9% of rows) — unitary authorities and the rest of the UK have no county tier.