Skip to content

Add OCD-IDs for UK Scottish Parliament, Senedd, wards, and CEDs - #433

Open
MiniCodeMonkey wants to merge 2 commits into
opencivicdata:masterfrom
Geocodio:feat/uk-political-district-coverage
Open

Add OCD-IDs for UK Scottish Parliament, Senedd, wards, and CEDs#433
MiniCodeMonkey wants to merge 2 commits into
opencivicdata:masterfrom
Geocodio:feat/uk-political-district-coverage

Conversation

@MiniCodeMonkey

Copy link
Copy Markdown
Contributor

Summary

Closes the OCD-ID coverage gap that downstream consumers run into when working with UK political districts. country-gb.csv previously only carried Westminster (/ed:) constituencies; this PR adds the four largest missing categories:

Type Path Rows
Scottish Parliament constituencies (spc) country:gb/part:sct/spc:<slug> 73
Scottish Parliament regions (spr) country:gb/part:sct/spr:<slug> 8
Senedd / Welsh Parliament constituencies (senc) country:gb/part:wls/senc:<slug> 40 (current) + 16 (May 2026)
Senedd electoral regions (senr) country:gb/part:wls/senr:<slug> 5 (abolished May 2026)
Electoral wards (ward) country:gb/part:<nation>/ward:<gss> 8,396 UK-wide
County electoral divisions (ced) country:gb/part:eng/ced:<gss> 1,366 (England only)

Total: ~9,900 new identifiers. NI Assembly is intentionally not touched -- post the 2023 OSNI review the boundaries are byte-identical to NI Westminster constituencies, so those ed: rows already serve.

Conventions

The path scheme follows the existing merged convention in constituencies.csv (extended most recently in #385). I've also added a gss_code extra column on every row that maps to a single ONS GSS code, mirroring the older country-uk files and #186 so consumers can crosswalk OCD-IDs ↔ GSS codes without a separate lookup.

A few specific calls worth flagging for review:

  • Type prefixes follow ONS column codes: spc / spr (Scottish Parliament constituency / region), senc / senr (Senedd constituency / region), ward, ced. These match modern ONS naming -- in particular senc / senr rather than the older nawc / nawr because the body was renamed from "National Assembly for Wales" to "Senedd / Welsh Parliament" in 2020 and ONS now ships senc22cd / senr22cd columns. Happy to switch to nawc / nawr for backwards parity with migrate country:uk ids to country:gb v1 #186 if that's preferred.

  • Hierarchy retained (country:gb/part:sct/spc:slug) for consistency with the current constituencies.csv rather than going flat (country:gb/spc:slug) per migrate country:uk ids to country:gb v1 #186. The original objection in Incorrect Country Code used for United Kingdom #184 that hierarchy implies geographic scope is specifically about Westminster (a UK-wide body); for Scottish Parliament / Senedd the part-nation nesting is geographically truthful. Either way the typed prefix carries the disambiguation, so I'm fine flipping to flat if reviewers want to pull the trigger on the migrate country:uk ids to country:gb v1 #186 direction in this PR -- just let me know.

  • Wards keyed on GSS, not name, because UK ward names collide nationally (21 distinct "Castle" wards). They're nested under part:<nation> rather than lad: or council: since this repo doesn't yet have UK Local Authority District identifiers; adding those is a much bigger change and out of scope here.

  • Senedd 2026 transition marked with validThrough=2026-05-05 on the 40+5 old rows and validFrom=2026-05-06 on the new 16 rows. The new rows use placeholder GSS codes W92000001-W92000016 (DataMapWales' internal numbering) because ONS hasn't published canonical 2026 GSS codes yet; once they do, those rows will need a sameAs plus a refreshed gss_code.

Sources

  • Westminster, Scottish Parliament, Senedd (current), wards, CEDs: ONS Open Geography Portal -- Open Government Licence v3.0.
  • Senedd post-May-2026 constituencies: DataMapWales (Welsh Government, OGL v3.0).

Validation

  • python3 test/compile_test.py passes (TEST_TMPDIR set).
  • Recompiled identifiers/country-gb.csv is included in the diff.
  • All new IDs validate against the regex in scripts/compile.py.

Refs

cc @chris48s @jpmckinney @sguenther85 -- given the unresolved conventions discussion in #170 / #184, would appreciate your steer on the hierarchy + prefix choices before this gets too far.

Closes the gaps in country-gb coverage flagged by downstream consumers
that key on OCD-IDs:

* Scottish Parliament: 73 constituencies + 8 regions (`spc:` / `spr:`)
* Senedd / Welsh Parliament: 40 + 16 constituencies + 5 regions, with
  validFrom/validThrough markers for the May 2026 boundary flip
  (`senc:` / `senr:`)
* Wards: 8,396 UK-wide wards (`ward:<gss>`)
* English county electoral divisions: 1,366 entries (`ced:<gss>`)

Wards and CEDs key the slug on the canonical ONS GSS code rather than
a name slug because UK ward names collide nationally (e.g. there are
21 distinct "Castle" wards). Constituencies and regions retain
name-based slugs since their names are unique within type.

Path scheme matches the prefixes (spc, spr, ward, ced) listed in the
existing scripts/country-uk/README.md, brought under the active
country:gb/part:<nation>/ tree. Body-name update: senc/senr replace
the old nawc/nawr (the body has been called "Senedd" since 2020).

Senedd 2026 source: DataMapWales senedd_final_2026 (Welsh Government,
OGL v3.0). 16 placeholder GSS codes W92000001-W92000016 -- ONS hasn't
published canonical 2026 codes yet.

NI Assembly is intentionally not included: post-2023 OSNI review the
boundaries are byte-identical to NI Westminster constituencies, so
those `ed:` rows already serve.

Tested with `python3 test/compile_test.py` (TEST_TMPDIR set).
* Add a `gss_code` extra column to scottish_parliament.csv,
  senedd.csv, wards.csv, county_electoral_divisions.csv -- mirrors
  the column carried by the older country-uk files and the stalled
  opencivicdata#186 migration so consumers can crosswalk OCD-IDs <-> GSS codes
  without a separate lookup.
* Expand README with explicit context on:
  - why senc/senr (modern ONS column codes, post-2020 Senedd rename)
    rather than the nawc/nawr used by opencivicdata#186 (which predates the rename)
  - the unresolved hierarchy debate raised in opencivicdata#170 / opencivicdata#184 / opencivicdata#186 --
    this PR follows the current merged convention but is willing to
    flip to the flat scheme if reviewers prefer.
@jpmckinney

jpmckinney commented Jul 4, 2026

Copy link
Copy Markdown
Member

#184 remains unresolved, but that's about what to do about the old uk.

In the meantime, I'd say we are unconstrained about gb.

Per the discussion in #184, I don't see a principled reason to have a proliferation of types like spc, spr, senc, senr, etc. especially when these types get renamed whenever a political body chooses to rename itself.

My understanding is that ONS organizes itself such that anything with the label "senc" is a Senedd / Welsh Parliament constituency – such that if the maintainers for Canada used that type for a different purpose, it would imply that there is a Senedd / Welsh Parliament constituency in Canada. This project doesn't organize itself that way.

As such, we can simplify and use e.g. ed (electoral district) for constituency (like in most countries), region for regions, and ward for wards.

GSS sounds fine to me. Canada also used numeric codes, but when these became unstable across vintages (and when we wanted to extend coverage into the past, for which we had no IDs), we switched to full names (and aliased the old numbers). It sounds like for gb we'd have to add local authorities to avoid numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants