Decode a GB postcode with Postcode-decode

As a development of my recent work on online maps, I have built Postcode-decode, an online service which tells you interesting stuff about any Great Britain postcode.

Instructions: type in a postcode for a location in England, Scotland or Wales (with or without the space, in capitals or lower case), and hit Decode it. That’s it. Try it here.

Most of the data, as well as the map, is courtesy of Ordnance Survey’s OpenSpace API. (It’s great to see Ordnance Survey offering so much open data, given where it’s come from.) The calculations for longitude, latitude and distance are made by Jonathan Stott’s PHPCoord code, which is his copyright and available under the GNU General Public License. Westminster constituency data (which Ordnance Survey could consider putting into a future version of OpenSpace) comes from MySociety.

As an example, putting in MK3 6EB – the postcode of Bletchley Park – gets you what is shown below. You also get links to the BBC weather forecast for the location, an AA route from central London to it, an alternative streetmap, information on local parking, property for sale, credit ratings, data from MySociety’s MapIt service… and even nearby National Trust properties, as well as a Google satellite image. Click here to see the results for Bletchley Park in full.

Bletchley Park postcode decoded

I wrote most of the code in PHP, except for the Javascript that produces the Ordnance Survey map. If you fancy putting something similar on your own site the code is available on GitHub, and you can see it working in a no formatting PHP-only fashion here. You will need to get a free Ordnance Survey OpenSpace API key. If you want to use it within WordPress as on this site, the PHP can be run through the Allow PHP plug-in and the Javascript through the Raw HTML one.

The code is copyright me except for the clever bits by Jonathan Stott, and is all available for re-use under the GNU General Public Licence. ‘Home’ is set to Trafalgar Square, but I have made it easy to change in the source code; there are instructions on GitHub.

I have done a reasonable amount of testing, but can’t guarantee accuracy (to state the obvious: don’t use it for anything really important). If you find anything going wrong, let me know. Thanks!