How to (not) build an elections map

772 views

Published on

Code for South Africa built the Mail & Guardian's 2014 General Elections Map (http://mg.co.za/data/2014-05-07-live-elections-2014-results). In this talk by Jason Norwood-Young, first given to the Hacks/Hackers group in Cape Town on 30 May 2014, he discusses the trials, tribulations, and more trials of building an elections map.

Published in: News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
772
On SlideShare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

How to (not) build an elections map

  1. 1. How to (not) build an election map Jason Norwood-Young Code4SA jason@code4sa.org
  2. 2. Code4SA “Everyone has the right of access to any information held by the state; and any information that is held by another person and that is required for the exercise or protection of any rights.” South African Constitution (Section 32) http://code4sa.org
  3. 3. Elections 2009
  4. 4. Then, in 2012…
  5. 5. 2014 HTML Data Mobile 2009 Flash Multimedia Web
  6. 6. News24 • 1.7 Million Unique Users • 22 Million Page Views • 30,000 app downloads • 102,000 concurrent users • … just on the day after the elections source: http://www.bandwidthblog.com/
  7. 7. Mail & Guardian • Map accounted for 10% of traffic • 5,000 concurrent users on the map • 22,674 unique users • 54,475 sessions • 85,668 pageviews • Avg session duration: 9m29s source: Google Analytics, TechCentral
  8. 8. That’s nice, but I thought this was about maps, not statistics
  9. 9. Data Information Presentation Knowledge
  10. 10. First, the APIs
  11. 11. Mix in a bit of inspiration http://afrith.github.io/election-web
  12. 12. Start visualising
  13. 13. Our first look - all the provinces, municipalities, wards
  14. 14. Adding some color
  15. 15. Pulling back a bit
  16. 16. Mario Maps!
  17. 17. Fighting with the maps
  18. 18. Large parts of the country don’t have wards (2009)
  19. 19. EC Ward in KZN? WTF
  20. 20. That’s okay EC, have some KZN islands
  21. 21. Fighting with the IEC
  22. 22. Contacting the IEC (This isn’t a link - it’s an IMAGE)
  23. 23. At least we had plenty of time for testing…
  24. 24. east we got the API documentation in g Election day: Wednesday 7 May 2014
  25. 25. we had known about the FRICKING MYSQL REPLICATION OP
  26. 26. Voting Day
  27. 27. May 7, 10:16am
  28. 28. • 7am - 2pm • Throw out 2009 Wards maps • Throw out seat allocation graphic • Add names to map • Add party flags • 2pm - 3pm • Vote • 3pm - 6pm • Final fixes to map • 6pm - 7pm • Rest, dinner • 7pm - 9pm • Integrate with IEC API • 9pm - 5:54am • PANIC!!!! • 5:54am - 10am • Sleep • 10am onwards • PANIC some more
  29. 29. Fun on the day • IEC API reports that a Voting District has changed (pull, not push) • We fetch the changed VD • We fetch the changed Munic (No ward data available) • We fetch the changed Province • Have to do this for Provincial and National • Takes approximately 4 seconds for one result
  30. 30. 4 (seconds) * 22,000 (voting districts) * 2 (provincial, national) = 176,000 seconds or 2,933 minutes or 49 hours
  31. 31. Meanwhile, IEC is giving us bullshit data which means we’re giving bullshit data
  32. 32. At 12pm on 8 May I decided to turn off ward reporting
  33. 33. But a few days later (Thanks to Adrian Frith who quickly scraped the data)
  34. 34. Wards are back, baby!
  35. 35. And now we have Voting Districts!
  36. 36. So who did the best maps? • Media24 had the most up-to-date, accurate data • We had the coolest • Adrian Frith had the awesomest (and continues to do the most with the maps) • Everyone else kinda sucked
  37. 37. http://adrianfrith.com/
  38. 38. Lessons • Data accuracy should come first, second and third • Don’t trust the data • Check, double-check, triple-check, and then get someone else to check • I’m too old for all-nighters
  39. 39. What’re the 2016 Elections going to look like? • Mobile • Waaay more data • A more sophisticated, data-literate reader • They’re maps, Jim, but not as we know it…
  40. 40. Tech Stack • Code4SA Elections API • Python (Flask) • http://election-api.code4sa.org/ • Interface to IEC API • Node.js • Middleware btw Code4SA API and IEC API interface • Python (Flask) • Maps API • Node.js, Topojson, Restify • Front end • D3.js • Bootstrap 3 • CodeKit
  41. 41. Embed your own <link rel="stylesheet" href="http://election-map.code4sa.org/res <div id="Code4SA" style="height: 100px"></div> <script src="http://election-map.code4sa.org/code4sa-ck.js" typ <script>Code4SA.Map.deploy();</script>
  42. 42. But was it worth it?
  43. 43. Yes, but only because of the APIs http://maps.code4sa.org/ http://election-api.code4sa.org/
  44. 44. – Emma Goldman “If voting changed anything, they’d make it illegal.”

×