Coder Social home page Coder Social logo

gedotmap's Introduction

View the app here.

Background

We wanted to build a different kind of electorate map that could provide a better visual representation of voter density and diversity at a single glance.

The standard electorate map tends to be the choropleth style. These maps will typically fill an entire constituency with the colour of the winning party. Although this gives a definitive guide of seat winners, it fails to visualise any diversity of voting within the constituency and the number of ballots cast.

The dot density approach has the benefit of representing votes for parties that did not win in each constituency. It also does not suffer from the tendency of over-emphasising the influence of large, yet sparsely populated areas, as colour-coverage is dictated by voter count, not constituency area size.

For more information about the benefits of dot density mapping, listen to the wise words of Bill Rankin here.

Process

The app was built with R, utilising the leaflet package and Shiny. You can view the source code here - suggested improvements welcome! (any way to speed up the dot plotting in leaflet? see below)

Plotting all dots at once was causing a lot of browser meltdown, hence the region splits.

To limit the number of colours on the map, for general election results, we've only included votes for the 6 largest parties in the UK by voter count. Northern Ireland has therefore been removed as a region option.

Voter numbers for each constituency are divided by 250. The resulting number of dots are then randomly distributed within the constituency boundaries, colour-coded by party.

For example, Labour received 30,633 votes in Hackney South & Shoreditch in 2015, so there will be 122 red dots (rounded down to nearest integer) randomly spread across that area. The exact location of each dot therefore does not have any significant meaning.

The number of EU Ref dots for Leave and Remain votes in each constituency were estimated (very crudely) in the follwing way:
((18+ Population 2015 figure * 0.722) * % Leave/Remain Estimate) / 250
With 0.722 being the average voter turnout % in the EU ref and the resulting figure representing 250 votes.

The bar chart shows the count of all visable dots on the screen for each party * 250. Due to the rounding process in dot plotting, not all votes will be represented in each constituency so this number will not be exact but should give a good representation of vote distribution amongst parties in any given area you zoom to on the map.

A note on zoom levels: it is best to view high density (urban) areas at a closer zoom level to avoid the order in which dots are plotted having an influence in the colour blend (Green dots will have more prominence from wider zooms because they are plotted last and will therefore cover dots below them).

Credits

Thanks to Alasdair Rae for making his excellent constituency shapefile available with all data embedded. You can find the full breakdown of sources on his blog post.

EU Referendum % esitmates for each constituency were computed by Chris Hanretty. Read his blog post that summarises the findings of his academic article "Areal Interpolation and the UK's referendum on EU Membership", Journal Of Elections, Public Opinion And Parties, accesible here.

Inspiration for the layout and dynamic bar chart was taken from the shiny superZIP example.

For more information about Culture of Insight get in touch via email or twitter @datasetfree

gedotmap's People

Contributors

paulc91 avatar

Watchers

James Cloos avatar PRUDHVI RATNA BADRI SATYA 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.