Contact

info@theinformationlab.co.uk
t 08453 888 289

One Alfred Place
London
WC1E 7EB

Newsletter

Subscribe
« The secret of a long life, move to Kensington and Chelsea | Main | Simple forecasting using Tableau »
Wednesday
Jul142010

UK Postcode mapping in 5 minutes

 

I have read a number of posts lately detailing approaches for handling mapping postcode data in the UK, so I thought I would write another one.  I think this is the fastest way to achieve it.

To map postcodes in Tableau, you somehow need to get the postcode

converted to a latitude and longitude.  There are many ways to do this, but I think this has the least steps.

Follow these steps to map the OUTCODE (the left hand side of a post code) to a Lat/Long.  The assumption is that you already have a dataset which includes POST CODE

Minutes 1 and 2 – Add a csv file to your copy of Tableau desktop, this tells Tableau the Lat/Long of the outcodes

You’ll need a csv file of outcodes, so I have posted one here.  Copy this file and save it.

Add it to tableau LIKE THIS…  Choosing the csv file from your save location.

image

 

Minute 3 – Create a calculated field which grabs the outcode from the postcode.  The function for the calculated field is something like this:

left([Postcode], find([Postcode], " ")-1)

This finds the space in the postcode, and returns the left portion which is equivalent to the outcode in the csv file.

image

 

Minute 4 – Change the ‘geographic role’ of your calculated field to be outcode.  Outcode is now available as a geographic role because of the csv file added

image

 

Minute 5 – Now you should be able to plot the outcode against a measure.  Select the outcode field, select ‘number of records’ (for example) and show me should now offer you a map.  Hey pesto, postcode mapping!

 

image

 

 

 

 

Happy mapping.

Tom

Reader Comments (11)

Tom - thanks so much for this post that Joe at Tableau pointed me towards. The clear description and handy csv of lat/long for UK Postcode Outcodes had me up and running in 5 minutes as promised.

I don't suppose you have any advice to help create polygon shapes for UK geographic areas (postcode areas, geographic regions, parliamentary constituencies etc) to create thematic maps? That would be really useful!

December 16, 2010 | Unregistered CommenterAndy L

Hi Andy,

Thanks for your thanks! I have worked with polygon shapes before, so should be able to help with this. I'll email you...

Tom

December 31, 2010 | Registered CommenterTom Brown

This is great, but sadly I REALLY need one including ALL the uk postcodes.. its inpossible to find on the net one already configured for use in Tableau...

Any ideas?

February 23, 2011 | Unregistered CommenterRichie

Hi Richie,

Try this file - http://bit.ly/dS0As6 - its not perfect, some postcodes are missing Lat Longs, but I think it will be good for most requirements.

It came from Wikileaks - although the web is littered with references to free postcode datasets being available for the UK, I can't find them either!

Hope this helps.

Tom

February 24, 2011 | Unregistered CommenterTom Brown

Richie,

This is a better source of the data I would say:

https://www.ordnancesurvey.co.uk/opendatadownload/products.html

There is some work to clean up the data and join into the descriptions (if you want borough and ward data). Shout if you need help with this.

Tom

February 25, 2011 | Unregistered CommenterTom Brown

Hello Again, I found that link to the ordinance survey data myself while having a google before my post, however none of it is configured to automatically read like the one at the top of this page. You just get an error while trying to import it. Although I’m a keen IT'er I’m still very new to tableau and I’m a bit stuck as towards how to actually get it to display the data I need, specifically the north west of England

65m people live in the UK, I thought somebody would of tackled this before me :)

Thanks for your help Tom, do you happen to know what changes ill need to make and how to inport the data into tableau?

Richie

February 28, 2011 | Unregistered CommenterRichie

Drop me an email Richie - will be easier to help you out than via commenting.

tom.brown@theinformationlab.co.uk

Tom

February 28, 2011 | Unregistered CommenterTom Brown

Hi Tom

I am trying to upload all the geographic coordinates of the UK, that is postcodes, regions, counties, local authorities, and parliamentary constituencies.

I have all the data that I need, although not the longitude and latitude.

It seems that uploading the outcodes, following your instructions work well, however I can not upload the counties, as it asks me for Country and State, saying that without these it can not upload.

I would also need data for regions, local authority and constituencies. Could you shed any light on this.

Uploading one of the tables from a different blog in the tableau format, for counties works fine, however when I then upload the outcodes, it does not let me blend the data as they have no common field. How do you solve this?

Ideally what I want is to build my UK maps, sometumes by postcode (or outcode) also by region, county and so forth

Could you please help?

any help would be highly appreciated.

Thanks

Oscar

April 7, 2011 | Unregistered CommenterOscar

there's a good tool here too:

http://www.gpsvisualizer.com/geocoder/

gives long and lat for any address

July 19, 2011 | Unregistered CommenterTips For Excel

Thanks Tom
Just loaded the UK postcode data and it works exactly as per your instructions. A great introduction to Tableau!
Bob

January 23, 2012 | Unregistered CommenterBob Bell

Thanks Bob, if you found this useful, then you should try looking at this post to get access to all the UK postcode data:

http://theinformationlab.co.uk/blog/2011/3/14/hopefully-the-last-word-on-uk-postcode-mapping-in-tableau.html

Also, if you'd like more information like this, we produce a newsletter designed to help people learning or using Tableau - drop me a line and I'll get you added to the distribution list (tom.brown@theinformationlab.co.uk)

Cheers

Tom

January 24, 2012 | Unregistered CommenterTom Brown

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>