How did "vote-splitting" affect the 2011 Canadian election?
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
data_munging
js
styles
README.md
index.html
package.json
webpack.config.js

README.md

2011 Canadian Election Vote Splitting

How did so-called "vote splitting" affect the 2011 Canadian federal election? This visualization aims to help you answer that question by interactively playing with different hypothetical changes in voter behaviour.

Check out the online version

Generating Election results CSV

  • Download this zip file with full riding-by-riding results from Elections Canada (it's linked from here).

  • Join all of the poll results csv files into one mega-csv with cat pollresults_* > joined.csv

  • Convert this csv's encoding from iso-8859-1 to utf8 with iconv -f iso-8859-1 -t utf-8 joined.csv > joined-utf8.csv

  • We need to cut out a lot of fat from this csv, and sum up each riding's totals. Run data_munging/csv_consolidator.js joined.csv > trimmed_results.csv (you may need to bring joined.csv into the same directory, of course).

Generating Map TopoJSON

First, download and unzip the shapefile from https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm

You'll want to choose "Federal Electoral Districts" and "Cartographic Boundary File"

Then run the following (you will need to npm install topojson first):

topojson -p +districtId,districtName,+totalVotes,+CPC,+LPC,+NDP,+GPC,+BQ \
    --simplify-proportion 0.4 -q 3000 \
    -e trimmed_results.csv --id-property=+FEDUID,+districtId \
    -o districts.topojson \
    gfed000b11a_e.shp

The topojson CLI reference has more tips that can likely reduce the filesize further.

Running locally

npm install
npm start

And then visit localhost:8080 in your browser.

Alternately, npm build will create the js/css files for you if you want to deploy to a static hosting site (like Github pages).

Misc links and alternate data sources