{"id":61904,"date":"2015-10-26T10:32:18","date_gmt":"2015-10-26T10:32:18","guid":{"rendered":"http:\/\/samathieson.com\/sa-mathieson\/?p=61904"},"modified":"2015-10-26T10:32:18","modified_gmt":"2015-10-26T10:32:18","slug":"decode-a-gb-postcode-with-postcode-decode","status":"publish","type":"post","link":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/","title":{"rendered":"Decode a GB postcode with Postcode-decode"},"content":{"rendered":"<p>As a development of <a href=\"https:\/\/samathieson.com\/sa-mathieson\/new-maps-with-mapbox\/\">my recent work on online maps<\/a>, I have built <a href=\"https:\/\/samathieson.com\/sa-mathieson\/data\/postcode-decode\/\"><strong>Postcode-decode<\/strong><\/a>, an online service which tells you interesting stuff about any Great Britain postcode.<\/p>\n<p>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&#8217;s it. <a href=\"https:\/\/samathieson.com\/sa-mathieson\/data\/postcode-decode\/\">Try it here.<\/a><\/p>\n<p>Most of the data, as well as the map, is courtesy of <a href=\"https:\/\/www.ordnancesurvey.co.uk\/business-and-government\/products\/os-openspace\/api\/index.html\" target=\"_blank\">Ordnance Survey&#8217;s OpenSpace API<\/a>. (It&#8217;s great to see Ordnance Survey offering so much open data, g<a href=\"https:\/\/samathieson.com\/sa-mathieson\/on-the-road-with-openstreetmap-wikimapping-the-isle-of-wight\/\">iven where it&#8217;s come from<\/a>.) The calculations for longitude, latitude and distance are made by <a href=\"http:\/\/www.jstott.me.uk\/phpcoord\/\" target=\"_blank\">Jonathan Stott&#8217;s PHPCoord code<\/a>, which is his copyright and available under the <a href=\"http:\/\/www.jstott.me.uk\/gpl\/\" target=\"_blank\">GNU General Public License<\/a>. Westminster constituency data (which Ordnance Survey could consider putting into a future version of OpenSpace) comes from <a href=\"http:\/\/mapit.mysociety.org\/\" target=\"_blank\">MySociety<\/a>.<!--more--><\/p>\n<p>As an example, putting in MK3 6EB &#8211; the postcode of <a href=\"http:\/\/www.bletchleypark.org.uk\/\" target=\"_blank\">Bletchley Park<\/a> &#8211; 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&#8217;s MapIt service&#8230; and even nearby National Trust properties, as well as a Google satellite image. <a href=\"https:\/\/samathieson.com\/sa-mathieson\/data\/postcode-decode\/postcode-decoded\/?search=MK3%206EB&amp;x=486386.32&amp;y=233931.65&amp;natgrid=SP864339&amp;long=-0.743141&amp;lat=51.997121&amp;place=Bletchley&amp;county=Milton%20Keynes&amp;ctype=Unitary%20Authority&amp;borough=none&amp;btype=&amp;region=South%20East%20England&amp;distance=68.9\">Click here to see the results for Bletchley Park in full<\/a>.<\/p>\n<p><a href=\"https:\/\/samathieson.com\/sa-mathieson\/data\/postcode-decode\/postcode-decoded\/?search=MK3%206EB&amp;x=486386.32&amp;y=233931.65&amp;natgrid=SP864339&amp;long=-0.743141&amp;lat=51.997121&amp;place=Bletchley&amp;county=Milton%20Keynes&amp;ctype=Unitary%20Authority&amp;borough=none&amp;btype=&amp;region=South%20East%20England&amp;distance=68.9\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-61905 size-full\" src=\"https:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\" alt=\"Bletchley Park postcode decoded\" width=\"614\" height=\"888\" srcset=\"https:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg 614w, https:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718-207x300.jpg 207w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p>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 <a href=\"https:\/\/github.com\/samathieson\/postcode-decode\" target=\"_blank\">the code is available on GitHub<\/a>, and you can <a href=\"http:\/\/samathieson.com\/postcode-decode\/\" target=\"_blank\">see it working in a no formatting PHP-only fashion here<\/a>. You will need to get <a href=\"https:\/\/www.ordnancesurvey.co.uk\/business-and-government\/products\/os-openspace\/api\/index.html\" target=\"_blank\">a free Ordnance Survey OpenSpace API key<\/a>. If you want to use it within WordPress as on this site, the PHP can be run through <a href=\"https:\/\/wordpress.org\/plugins\/allow-php-in-posts-and-pages\/\" target=\"_blank\">the Allow PHP plug-in<\/a> and the Javascript through <a href=\"https:\/\/wordpress.org\/plugins\/raw-html\/\" target=\"_blank\">the Raw HTML one<\/a>.<\/p>\n<p>The code is copyright me except for <a href=\"http:\/\/www.jstott.me.uk\/phpcoord\/\" target=\"_blank\">the clever bits by Jonathan Stott<\/a>, and is all available for re-use under <a href=\"https:\/\/github.com\/samathieson\/postcode-decode\/blob\/master\/LICENSE\" target=\"_blank\">the GNU General Public Licence<\/a>. &#8216;Home&#8217; is set to Trafalgar Square, but I have made it easy to change in the source code; there are instructions on GitHub.<\/p>\n<p>I have done a reasonable amount of testing, but can&#8217;t guarantee accuracy (to state the obvious: don&#8217;t use it for anything really important). If you find anything going wrong, let me know. Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s &hellip; <a href=\"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Decode a GB postcode with Postcode-decode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[10,11],"tags":[],"class_list":["post-61904","post","type-post","status-publish","format-standard","hentry","category-it","category-maps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Decode a GB postcode with Postcode-decode<\/title>\n<meta name=\"description\" content=\"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Decode a GB postcode with Postcode-decode\" \/>\n<meta property=\"og:description\" content=\"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/\" \/>\n<meta property=\"og:site_name\" content=\"SA Mathieson\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-26T10:32:18+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\" \/>\n<meta name=\"author\" content=\"SA Mathieson\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SA Mathieson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/\"},\"author\":{\"name\":\"SA Mathieson\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/#\\\/schema\\\/person\\\/3606fa34fc4a527f20eeb5a32ff83a36\"},\"headline\":\"Decode a GB postcode with Postcode-decode\",\"datePublished\":\"2015-10-26T10:32:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/\"},\"wordCount\":392,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\",\"articleSection\":[\"IT\",\"Maps\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/\",\"url\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/\",\"name\":\"Decode a GB postcode with Postcode-decode\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\",\"datePublished\":\"2015-10-26T10:32:18+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/#\\\/schema\\\/person\\\/3606fa34fc4a527f20eeb5a32ff83a36\"},\"description\":\"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.\",\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/decode-a-gb-postcode-with-postcode-decode\\\/#primaryimage\",\"url\":\"http:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\",\"contentUrl\":\"http:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/Bletchley-Park-postcode-decoded-e1445532454718.jpg\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/#website\",\"url\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/\",\"name\":\"SA Mathieson\",\"description\":\"Journalist, editor, analyst and trainer on computing, government, climate and data\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/#\\\/schema\\\/person\\\/3606fa34fc4a527f20eeb5a32ff83a36\",\"name\":\"SA Mathieson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g\",\"caption\":\"SA Mathieson\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/samathieson\"],\"url\":\"https:\\\/\\\/samathieson.com\\\/sa-mathieson\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Decode a GB postcode with Postcode-decode","description":"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/","og_locale":"en_GB","og_type":"article","og_title":"Decode a GB postcode with Postcode-decode","og_description":"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.","og_url":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/","og_site_name":"SA Mathieson","article_published_time":"2015-10-26T10:32:18+00:00","og_image":[{"url":"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg","type":"","width":"","height":""}],"author":"SA Mathieson","twitter_misc":{"Written by":"SA Mathieson","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#article","isPartOf":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/"},"author":{"name":"SA Mathieson","@id":"https:\/\/samathieson.com\/sa-mathieson\/#\/schema\/person\/3606fa34fc4a527f20eeb5a32ff83a36"},"headline":"Decode a GB postcode with Postcode-decode","datePublished":"2015-10-26T10:32:18+00:00","mainEntityOfPage":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/"},"wordCount":392,"commentCount":0,"image":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#primaryimage"},"thumbnailUrl":"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg","articleSection":["IT","Maps"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/","url":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/","name":"Decode a GB postcode with Postcode-decode","isPartOf":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/#website"},"primaryImageOfPage":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#primaryimage"},"image":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#primaryimage"},"thumbnailUrl":"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg","datePublished":"2015-10-26T10:32:18+00:00","author":{"@id":"https:\/\/samathieson.com\/sa-mathieson\/#\/schema\/person\/3606fa34fc4a527f20eeb5a32ff83a36"},"description":"Postcode-decode is an online service that provides data on postcodes in England, Scotland and Wales, mainly from Ordnance Survey. Source code on GitHub.","inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/samathieson.com\/sa-mathieson\/decode-a-gb-postcode-with-postcode-decode\/#primaryimage","url":"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg","contentUrl":"http:\/\/samathieson.com\/sa-mathieson\/wp-content\/uploads\/2015\/10\/Bletchley-Park-postcode-decoded-e1445532454718.jpg"},{"@type":"WebSite","@id":"https:\/\/samathieson.com\/sa-mathieson\/#website","url":"https:\/\/samathieson.com\/sa-mathieson\/","name":"SA Mathieson","description":"Journalist, editor, analyst and trainer on computing, government, climate and data","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/samathieson.com\/sa-mathieson\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/samathieson.com\/sa-mathieson\/#\/schema\/person\/3606fa34fc4a527f20eeb5a32ff83a36","name":"SA Mathieson","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/023c08559e663aa567033c4c53dea808a97496ecb3e08431abc1a347ef45782b?s=96&d=mm&r=g","caption":"SA Mathieson"},"sameAs":["https:\/\/x.com\/samathieson"],"url":"https:\/\/samathieson.com\/sa-mathieson\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/posts\/61904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/comments?post=61904"}],"version-history":[{"count":7,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/posts\/61904\/revisions"}],"predecessor-version":[{"id":65202,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/posts\/61904\/revisions\/65202"}],"wp:attachment":[{"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/media?parent=61904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/categories?post=61904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samathieson.com\/sa-mathieson\/wp-json\/wp\/v2\/tags?post=61904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}