UK Election Map [Indiemapper Made]
Posted by daveI have a confession to make: I don’t make as many maps as I used to. My role in Axis Maps usually has me leaving the mapping to our talented designers and developers while I scurry off to do business-y things. I wanted to get back into the swing of making some maps so I thought I would try my hand creating a wrap-up of the 2010 UK election. I posted the IMPs with each map if you want to download my maps and make your own versions!
Full disclosure: I’m American but Britain is my adopted home. I apologize in advance to any UK natives for any inaccuracies resulting from my cursory knowledge of your political system. Let me have it in the comments!
Preparing the data table
My first order of business was locating the election data. I initially started looking for a KML or shapefile containing the election data. However, 3 Google searches later, it looked as if that was a pipe dream. However, what I did find was a VERY complete election table from The Guardian’s Datablog. You can see and download the full spreadsheet on this Google Doc.
The spreadsheet was very complete, but the way it was organized was going to be a problem for getting it on a map. Each party candidate for each constituency was given its own line in the spreadsheet.
Because I am going to be attaching this spreadsheet to geographic data, I needed to alter the layout so there would only be one entry for each constituency. Party information that was currently stored as individual rows would need to be translated into columns. I created a Pivot Table in Excel with constituency in rows and parties in columns. The table has records for 136 registered parties for the UK so I limited the table to the 3 major parties (Conservatives, Labour and Liberal Democrats). For the values in the table, I used number of votes and percentage of votes.
With the pivot table made, I pasted the data out of a pivot table so I could do a couple more calculations using the actual values. I grouped all of the other parties into their own group, copied information about the winning MP over from another table. Finally, I created four columns that only displayed the winning percentage if that party’s candidate won in that constituency (hopefully you’ll see why later). Now I have a final spreadsheet that is ready to get attached to some geographic data.
Getting some geography
After a quick Google search, I located the boundary shapefile I was looking for at data.gov.uk. You can download the file here: http://data.gov.uk/dataset/os-boundary-line. The constituency file comes bundled with lots of other boundary files that I’ll keep around in case I want to add it to my map later as context. A quick look at the data shows:
The data could definitely use some generalization, especially to clear up some of the denser constituencies around London and Birmingham. With Mapshaper, it will be about a 5 minute task. I uploaded the shapefile and generalized to 95% using the special Visvalingam method. Things look much cleaner and I reduced the file size of the .SHP from 68.4MB to 246KB.
Now I have to attach the table I created to the DBF associated with the shapefile. This requires OpenOffice (free download) since Microsoft Excel no longer has support for opening / editing DBF files. I opened both westminster.dbf (this is the DBF file that is part of the downloaded constituency shapefile) and uk_election.xls (the spreadsheet I created of election data) in OpenOffice. I sorted both tables by constituency name and pasted values from the election spreadsheet into the constituency DBF.
Note: At this point, it is very important to make sure your numerical values are stored as numbers instead of as text. Most spreadsheet programs align numbers to the right side and text to the left. If your numbers are stored as text, indiemapper will interpret them as any other kind of text and they will be available for labeling only.
I then ran a quick visual check to make sure the columns were lined up properly, comparing the constituency names from the DBF to the ones brought in from the DBF. I found a couple of discrepancies where my spreadsheet had something like “Yorkshire East” and the DBF had “East Yorkshire.” Doing a quick search through all the cardinal directions got this fixed pretty quick. I saved the DBF and now it was ready to be brought into indiemapper.
Making a map
I loaded my data into indiemapper and pretty quickly knew the map I was going to make. My idea was to create a proportional symbol map of the winners for each constituency where the size of the symbol was representative of their margin of victory. Since I was going to show each party using their respective colors, I was going to need separate proportional symbol layers in my map (which is why I divided the winning party values into different columns). Because each proportional symbol layer was coming from the same data source, I only needed to load in my shapefile once and then I could spawn each new proportional symbol layer from it.
With each layer created, I colored each one by political party and made sure they were classified and sized identically. I used made 3 classed symbols and set the bottom filtering control to 30% to remove all the zero values (where that party didn’t win). I made the other two class breaks at 40% and 50%. After adding transparency and stroke, I ended up with a map that looked like this:
I was pretty happy with it but knew it could use some work. So I called in some colleagues to help me out with the map.
Collaboration
I wanted to get some other people to take a look at my map. I went to My Indie page and invited Mark as a collaborator. This would enable him to see my map and make whatever changes to it he thought it needed.
When I clicked submit, Mark was automatically sent an email that gave him access to my project. I also turned on project notifications on the history page so if he commented on my map, I would be notified by email. When Mark threw down a comment, I was notified and I went to the history page to check it out.
He made a good point. I made a few quick styling changes to my map to bring the dots into the forefront, added a title, fixed my extent and I was done! Download the IMP and make your own edits…
Bonus Map
The coalition government between the Conservative and Liberal Democrat parties has faced no end to post-election dissection. No ink has been spared asking if a party from the right could work with a party from the left and if it actually represents the British people. I put together a quick bivariate choropleth map comparing the percentage of Conservative votes to the percentage of Liberal Democrat votes in each district. The blue areas are high Conservative but low Lib Dem; the areas of orange are high Lib Dem but low Conservative. The areas of “Brown” (ironically enough) are relatively high percentage for both are are the most aptly represented by the Camereon – Clegg coalition. Download the IMP and make your own edits…











June 1st, 2010 at 12:03 pm
Looks nice! I have a similar (although not as pretty) map at http://oobrien.com/vis/election/
June 6th, 2010 at 7:56 am
Thanks for this. As a beginner at mapping and analysis, step-by-step recaps of projects like this are really helpful and instructive for thinking through different ways to solve mapping problems.