Giter VIP home page Giter VIP logo

votesplit2011's Introduction

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

votesplit2011's People

Contributors

af avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.