This repository contains source code used to generate notional election results for the 2021 Scottish Parliament had it been held on 2026 boundaries.
This code relies on data files which I do not have permission to redistribute, and which are not included in this repository.
These data files are as follows:
- population weighted centroids for 2022 census output areas, available at https://www.nrscotland.gov.uk/publications/2022-census-geography-products/
- output area counts by characteristic, available at https://www.scotlandscensus.gov.uk/documents/2022-output-area-data/
- shapefiles for 2022 census output areas, also available at https://www.nrscotland.gov.uk/publications/2022-census-geography-products/ -- note that these are only used for the report
- Scottish Parliamentary Constituency boundaries as of 2022, available at https://geoportal.statistics.gov.uk/datasets/ons::scottish-parliamentary-constituencies-december-2022-boundaries-sc-bfc-2/about
- Scottish Election Study data from 2021, available at https://github.com/ScottishElectionStudy/
- shapefiles for the 2026 constituencies, available at https://boundaries.scot/reviews/second-review-scottish-parliament-boundaries
- census microdata, available at https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=7834
- notional results from Ballot Box Scotland (used for comparison purposes), available at https://ballotbox.scot/scottish-parliament/sp-21-new-boundaries-notionals/
The outputs of this project are a set of CSV files:
consty_notionals.csv: a CSV file containing estimated vote counts for 2026 boundaries for all parties which stood candidates in constituency contests, according to the new constituency name, code number. The fieldSPC22CDconcatenates the codes of all "parent" constituencies, and should not be used for joining data sets.list_notionals.csv: as above, but for list contests.intersections_constyvote.csv: a CSV file containing estimated vote counts for all intersections between 2026 and 2021 boundaries. This can be useful to see where particular votes "came from".intersections_listvote.csv: as above, but for list contests.index_of_change.csv: a CSV file containing, for each constituency, an index of change between zero and one, which gives one minus the proportion of the new constituency's population that came from the principal "parent" constituency. If the constituency is unchanged, the value is zero.index_of_change_v2.csv: a CSV file containing, for each constituency, the contribution of the principal "parent" constituency, the number leaving that principal parent constituency, the number joining from other constituencies. The index of change is (leavers + joiners) / (electorate of the principal parent constituency). This figure matches the calculation used by broadcasters since 1983.
Finally, there is a report in posts/ which gives a narrative description of the process.