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

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 (], 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

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

City Centre filetype:kml

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.

HacksHackers Manchester – Web APIs for lunch

HacksHackersMcr tried a different format on 14th May – a Learning Lunch. Thanks to Rob for the idea and for leading the meet-up! And thanks to Ziferblat in the Northern Quarter for being the perfect venue.

Web APIs for journalists and… everyone

Application Programming Interface may not sound like funzies for a non-coding journalist but getting your head round them opens up all sorts of possibilities. Obviously, if you’re a dev, you’re going to go in a lot deeper and do some amazing things but that doesn’t mean there isn’t an entry level for journalists too.

An interface just means you have a way of getting at something you want. Let’s say you want to get photos posted on Flickr from a certain location or using a certain camera. You could do it the hard, laborious way…. Or you could use the Flickr API to make it simpler and quicker (relatively speaking). You just construct a specific type of URL in your ordinary browser, then send it to a server which interprets that URL request and sends you a bunch of the data you asked for. BUT, it will send it in computer-speak so it won’t look pretty. The data will probably be in JSON but you don’t need to be fluent in the JSON format to be able to use this data.

Flickr Web APIs – the basics

So, I’m no expert and I’m just playing around with this stuff at this stage but that means I can, at least, see the potential of APIs. I chose the Flickr API. Click on this link and on the right hand side, you’ll see a list of “methods” which just means the different types of data you might want to get at. When you click on one, it gives you further instructions about how to create your API. For a lot of them, you need to get authentication which I’m not going to go into here. So let’s choose a simple example which doesn’t require authentication. Under the People subheading, I clicked on getPublicphotos – which lets you get the data for the public photos of a particular Flickr user.

Now you’re ready to build your URL. Flickr APIs start with:-

Next, you need to specify which Method from that long list you’d like to access. So add this:-


What’s the Method? It tells you at the top of the page of instructions once you click on your chosen method. In this case it’s:-


Now, the instructions tell you there are various “arguments” you need to add to your URL. These are just further details to help the server return what you need. First of all, you need the API key and there are instructions on the page for how to get this password. It’s easy. So you add this to that URL you’re building:-


Then it asks you to add the user id (NSID) for the user whose photos you’re looking for. This is trickier (although maybe I’m missing a simple trick here?) but this is how I ended up getting the NSID for a user. It involves another API, ironically, but it’s a copy&paste job into your browser

That should return the NSID number so add that to your growing URL like this:-


Finally, let’s tell the server we’d like our data returned to us in JSON:-


Put that all together and you get something like this:-

Copy and paste into your browser and see what you get!

Screenshot JSON API request

Not so nice. But you can use a JSON to CSV converter to change this into a more familiar spreadsheet format by simply copying and pasting the text as it is into, say, 

Not hugely useful to a journalist but hopefully a way to understand how an API works and what it can do. So the next stage is to think of some more practical – yet still accessible – project I could work on with an API. Suggestions welcome!

Recommended Articles

Rob’s slides from the HacksHackersMcr Learning Lunch

Web APIs – Learning Lunch – Rob’s blog

Web APIs for non-programmers – a fabulous explainer by Noah Veltman

Hack the Election! Hacks/HackersMcr

Image of The Shed's doorThe great thing about organising Hacks/Hackers meet-ups is getting to meet amazing people from all walks of life who give their time generously and leave you feeling inspired. And hopefully everyone who came along to our event on Monday sixteenth of March felt similarly fired up by our guest speakers.

The Venue

Thanks to the brilliant team at MMU’s Digital Innovation for letting us use their fabulous, industrial space at The Shed. It meant we could provide tea and coffee to everyone on arrival which makes us feel all warm and hospitable! It’s also got full AV facilities and good wifi which meant our guests could show us the full range of their ideas and we also set up a Twitterwall so we could display the #HHMcr tweets as they happened!

Voter apathy?

The meet-up was all about finding inspiration on how to engage younger people in democracy and politics ahead of the election and even make it fun??!! As journalists, we know that although we get excited about elections, our audiences may not share that enthusiasm. Often, that’s because they don’t know where to find the information that can help them to get more involved. Or it may be because they don’t think the election is relevant to them especially here in Manchester with safe Labour seats leading to very low turnout.

The Speakers

Beth Ashton talking at HacksHackersMcrBeth Ashton, Social Media Editor at M.E.N. talked about how they’re putting together a Manchester Manifesto, asking the people of Manchester what they think are the big issues.

Next up was Francis Irving, CEO of Scraperwiki and the programmer behind They WorkForYou which parses Hansard data to show MP’s voting record in parliament. He talked about the suite of open democracy sites put together by Democracy Club .Francis Irving talking at Hacks/HackersMcr

  • YourNextMP - Find out who’s standing in your constituency and how to contact them
  • – Real-time monitoring of election leaflets. Keep track of how politicians are trying to get your vote!
  • Democracy Club’s CVs – a site to help candidates share their CVs with voters
  • MeetYourNextMP – find out how to meet the candidates standing in your constituency and question them with this site listing hustings by constituency.

One of my local candidates happened to be following me as I was tweeting about this and has promised to upload his CV! And, of course, these sites are great sources of potential stories and data for journalists.

Dan Hett talking at Hacks/HackersMcrTo round off the evening, Dan Hett – senior games developer at BBC Childrens, live coder extraordinaire and all-round creative person – inspired us to just go out there and make stuff that is awesome. Throw off your chains and don’t worry if it doesn’t work!

So if any of you were inspired by what you heard to make something, let us know!

Hacks/Hackers Manchester – Contributoria and Quarantine

Openness and participatory media were the broad themes of January’s Hacks/HackersMcr meet-up. What kind of magic happens if you open yourself up to a community of strangers either face-to-face or online? And is there such a thing as a free lunch – in the Northern Quarter, at least?

We were very pleased to welcome Dean Vipond of Contributoria.

“Contributoria is a community funded collaborative platform for journalists launched at the start of 2014 and supported by the Guardian Media Group in the UK. This cheeky short film has been created by illustrator Nic Hinton and animated by @BennyCrime and explains what’s on offer at the online platform. It was first shown at the International Press Institute conference in Johannesburg in January 2014.”


Dean even brought some revolutionary media product called a NEWSPAPER to share out. Hacks/Hackers were fascinated….

Paper copies of Contributoria


There was a very different presentation from artist, Richard Gregory, who talked about his conversation project in Manchester’s Northern Quarter. Walk in to the Kabana curry cafe on the right date, and you could get your lunch for free in return for engaging in conversation with the artists. You follow a conversation menu and just see where it takes you. Are there lessons to be learnt as we seek meaningful engagement with online communities?


As always, thanks to Kosmonaut for letting us hijack their basement and apologies to the table tennis players if we encroached on their game….