Generating coloured-in election map images with SVG

The Election Boundary Map generator in Firtl’s sandpit will attempt to match a text data file with an SVG image of the UK (actually only Great Britain since Northern Ireland is not on the Ordnance Survey map) showing political constituencies. Simply upload a text file with two fields on each line. The first field should be the name of the constituency, the second a numeric value such as a percentage. Separate the two fields with a space.

A coloured map will be generated to reflect the value in each constituency. The colours are drawn from a red-green-blue spectrum from 0 to 100%, or 0 to the maximum value found in the file if the “Stretch values” checkbox is set. Constituencies for which no matching name is found in the uploaded file will be left uncoloured.


The map images are available in PNG, JPEG and SVG. Here are PNG examples of the percentages of votes cast for some of the better-known options at the 2010 General Election, in alphabetical order:











Liberal Democrat


Plaid Cymru





The SVG maps were generated from data from the Ordnance Survey’s OpenData Boundary-Line product (sorry, can’t give a direct in-page link as OS’s HTML is broken). I used the free QGIS mapping application to export SVG from the OS data, but had to edit QGIS’ SimpleSvg plugin to embed constituency names from the ‘Attribute Table’ to allow more straightforward colouring of the map.

The data I used to colour the maps I found by visiting and following the link to the Electoral Commission’s General Election 2010 Results Data (sorry, no direct in-page link as the Electoral Commission’s HTML is insufficiently marked-up).

The electoral data is in one great Excel file (why not an open format?), which I transformed into individual files for upload to my map generator. Here are the files:

election2010bnp election2010conservative election2010green election2010independent election2010labour election2010libdem election2010plaidcymru election2010snp election2010ukip

Leave a Reply

Your email address will not be published. Required fields are marked *