how to (not) build an elections map
TRANSCRIPT
How to (not) build an election map
Jason Norwood-YoungCode4SA
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
Elections 2009
Then, in 2012…
2014HTML Data Mobile
2009Flash Multimedia Web
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/
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
That’s nice, but I thought this was about maps, not statistics
Data Information
Presentation Knowledge
First, the APIs
Mix in a bit of inspiration
http://afrith.github.io/election-web
Start visualising
Our first look - all the provinces, municipalities, wards
Adding some color
Pulling back a bit
Mario Maps!
Fighting with the maps
Large parts of the country don’t have wards (2009)
EC Ward in KZN? WTF
That’s okay EC, have some KZN islands
Fighting with the IEC
Contacting the IEC
(This isn’t a link - it’s an IMAGE)
At least we had plenty of time for testing…
Well, at least we got the API documentation in good time
Election day: Wednesday 7 May 2014
If only we had known about the FRICKING MYSQL REPLICATION OPTION!
Voting Day
May 7, 10:16am
• 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
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
4 (seconds) * 22,000 (voting districts) * 2 (provincial, national) =176,000 seconds
or2,933 minutes
or49 hours
Meanwhile, IEC is giving us bullshit data
which means we’re giving bullshit data
At 12pm on 8 MayI decided to turn off ward reporting
But a few days later(Thanks to Adrian Frith who quickly scraped the data)
Wards are back, baby!
And now we have Voting Districts!
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
http://adrianfrith.com/
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
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…
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
Embed your own
<link rel="stylesheet" href="http://election-map.code4sa.org/resources/css/style.css"><div id="Code4SA" style="height: 100px"></div><script src="http://election-map.code4sa.org/code4sa-ck.js" type="text/javascript"></script><script>Code4SA.Map.deploy();</script>
But was it worth it?
Yes, but only because of the APIs
http://maps.code4sa.org/
http://election-api.code4sa.org/
– Emma Goldman
“If voting changed anything, they’d make it illegal.”