Published

Canada (CA) build pipeline

Postal Codes Dataset for Canada, CA including name of the city, town, or place, various administrative divisions and alternative city names.

Canada (CA) build pipeline

Clean-room rebuild — GeoNames + StatCan open cartographic boundaries only. Must never read, join against, or validate itself with StatCan's Postal Code Conversion File (PCCF). PCCF is licence-gated (Canada Post / StatCan 92-154-X, via DLI) and its End-Use Licence forbids redistribution, deriving a commercial product from it, and publishing more than a 1% extract. Clause 3 bites on derivation, so PCCF may not sit open beside the build as a "just checking" reference either — a spatial join tuned until it agrees with PCCF is a PCCF derivative. fetch_sources.py's own docstring states this; integrity_checker.py and package.py hard-fail the build if admin_name3/admin_code3 (PCCF's old signature field) is ever non-empty.

An earlier, PCCF-dependent build (scripts/ca/pccf_parse.py, build_cduid.py, admin2_enrich.py — still committed at the repo root, not here) was superseded by this one on 2026-08-10/11. This is the pipeline that is actually live, confirmed by diffing the object sizes of the currently-published ca/ca.csv and ca/consolidated/latest/ca.csv in R2 against this pipeline's local output (both match exactly; see BUILD_LOG.md, sourced alongside this folder, for the fetch SHA-256s and join-correctness checks against 6 known cities).

One separate, real problem found 2026-08-19, not fixed by this pipeline change: the raw, licence-gated PCCF file itself (ca/pccf/canada_pccf.csv, ~65.7MB) is still sitting in the same R2 bucket this paid product ships from, dated before the clean-room rebuild. publish_r2.py has an --include-pccf flag built specifically to delete it — it was apparently never invoked. This needs a human decision (the deletion is irreversible), not an automated fix.

Run order

python3 fetch_sources.py       # GeoNames CA_full + StatCan CD/CSD cartographic boundaries only
python3 spatial_join_cd.py     # attach Census Division
python3 spatial_join_csd.py    # attach Census Subdivision
python3 build_base.py
python3 integrity_checker.py   # hard-fails if PCCF signature detected
python3 package.py
python3 publish_r2.py          # dry run by default; --apply to publish

Sources

  • GeoNames CA_full — CC BY 4.0
  • StatCan CD/CSD 2021 cartographic boundary files — Open Government Licence – Canada

Verification (2026-08-19)

899,779 rows. admin_name2 99.98% filled (293/293 census divisions), admin_name3 99.96% filled (3,724/5,161 census subdivisions) — more complete than the superseded PCCF build (94.2%/79.3%). R2 object byte-size match confirmed for both ca/ca.csv and ca/consolidated/latest/ca.csv; a full SHA-256 download comparison was started but not completed in the same session — size match across two independently timestamped uploads is strong evidence, not yet cryptographic proof.