Monthly Archives: April 2016

How to create KML shape file showing boundary lines of election districts, regions, wards, constituencies

Polling station

Photo by secretlondon123 CC by-SA 2.0 https://www.flickr.com/photos/secretlondon/

We have local elections on 5th May so we’re thinking about ways in which our students might cover the live results as they come in for our area – Manchester. I thought it would be good to use a map showing the electoral wards that make up Manchester City Council which we could update as the results came in. Something like this….

Contains Ordnance Survey data © Crown copyright and database right [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons

I want to keep it SIMPLE so I just want to stick with Google maps which we can embed easily on CoveritLive. This means finding (or creating) a .kml file which you can import simply into My Maps – without using any code. KML (Keyhole Markup Language) is a special file format for displaying geographical data. It’s especially handy if you want to show boundary lines round countries, counties, electoral wards etc. There are other file formats that do this, but they can’t be used with Google Maps.

Does the KML file already exist?

This is the obvious first step and you may get lucky. I believe some councils do make such maps available on their websites. I couldn’t find one for Manchester. You might also find that someone has already created a kml file for your area so a search in Google maps might yield results. Or a fellow blogger might have created and shared one. You can refine your search using operators:-

Manchester filetype:kml

Searching a council website…

…is often a thankless task. It’s often better to use a google search but with operators. I decided to see what kml files the council did keep with the following search request:-

Manchester filetype:kml in:manchester.gov.uk

which looks specifically for files ending .kml within the Manchester City Council website. After playing around with this, I discovered that the council did have kml files for individual wards. It also had a list of ward by ward election results from 2015. So, using the list of wards from 2015, I could search the Manchester Council website for each ward individually:-

Levenshulme filetype:kml in:manchester.gov.uk

City Centre filetype:kml in:manchester.gov.uk

Then, I simply downloaded the files onto my Mac.

So now I could import each ward into Google maps. Here’s how….

Importing KML files into layers in Google Maps

Create a new map in Google maps. See my previous post on using Google Maps. Click on import and import the first of those kml files you just downloaded. As if by magic, the outline of that ward will appear on your map. Create a new layer and import the kml file for the next ward. Do the same for all the wards until…..

Screenshot maps layers

Yep, turns out Google Map has a 10 layer limit and there are considerably more wards than that in Manchester and most places, I guess. So now I need to find out if there’s a way to merge the layers somehow or, perhaps, merge the kml files into one.

Merge KML files in Google Earth

I spent a lot of time Googling this one. There are certainly solutions out there but most of them involved some coding knowledge which I don’t have. But I came across a couple of posts which suggested the files could be merged simply by dragging them into a folder in Google Earth. That seemed do-able!

  1. Download Google Earth. This doesn’t seem to work at the moment on the Mac, annoyingly, so I had to download it on my laptop. I’d never used Google Earth before but I had no problem working it out for this simple exercise. The hyperlink above from Texas811 was very helpful.
  2. Open KML files in Google Earth. Just click File > Open and access the folder where you’ve saved all those kml files. These are now displayed in Google earth.
  3. Create a new folder in Google Earth and rename it. Add > folder. Drag all those kml files into this new folder.
  4. Save the folder as a new KML file. Do this by right clicking on the folder and clicking Save Place as. Save it to your computer.

You now have a single kml file that will display all the boundaries of all the wards in Manchester City Council in a single layer in Google Maps. Like this….


And that opens up all sorts of options for showing the results as they come in.