Subscribe to this feed

Navigation

Recent Posts

Archive

UK Post Code GeoCoding

Wednesday 13 Jun, 2007 - 12:01pm | 0 comments |

The PAF (Postcode Address File) is the complete address database of the UK containing over 27 million addresses and some 1.7 million post codes. Postzon is the Royal Mails product which links post codes with ordinance survey and grid reference data. These products are licensed by the Royal Mail and are not free which can make access to the data prohibitive for some users. 

As geocode data is freely available in countries such as Canada, Germany, Italy, Spain, France and the USA various hacks have been devised for the UK, including community compiled post code databases, and a petition, which can only be doomed to fail, to try and force the Royal Mail to release their data for free.

The Royal Mail is in the process of revising it's pricing structure, recognising it has in the past favoured larger organisations. The price changes are being phased in and will culminate in all licences being replaced with new terms and conditions on 1st September, 2009. Although these changes are welcome it still means the data isn't free and websites which are non commercial or have low levels of users may still need to look elsewhere if they wish to include mapping information in their web applications.

UK Post Codes are made up of two parts as in SW1A 2AA, the post code for Number 10 Downing Street. The first part is the outward code identifying the delivery office the mail has to go to, and the second part is the inward code which, when combined with the building name or number, gives the delivery point.

Part Meaning Number
SW The post code area 124 in the UK
SW1A The post code district Approximately 20 districts per area
SW1A 2 The post code sector Approximately 3,000 addresses per sector
SW1A 2AA The post code unit Approximately 15 addresses per unit.

The district codes (approximately 2,800) with latitude and longitude coordinates can be downloaded from Jibble, but if you want more precision in your maps you need to look at the full post code unit. 

The definitive tutorial on geocoding UK postcodes with Google Map API was written by Tom Anthony on his blog earlier in the year. He has since followed it up with Caching Google Maps Geocoder Results, another easy to follow well written tutorial on how to, at least temporarily, save your results. For a complete post code unit, however, there are on average 15 addresses so basing a marker on the post code unit will not be precisely accurate, i.e. it will not identify a specific address. To do that you need to include the building name or number.

Tom's method is based on form imput of the post code, but if you already have the post code in a database you can just call the javascript function directly, as in

<script type="text/javascript">
usePointFromPostcode('<?php echo $postcode; ?>', placeMarkerAtPoint);
</script>

The result, however, is a proximity map rather than identifying a specific address. Remember there are approximately 27 million addresses in the UK and only 1.7 million post codes.

Post Code data is not static and for licensed copies of the Royal Mail data there are regular updates. If you pass lat and long coordinates back into a database to avoid hitting the Google or Multimap servers to obtain the coordinates there is a risk, probably quite remote, of your data being out of date. You could mitigate this by adding a date field to your database table so you could check the lat long coordinates at a frequency, say every six months, or a year.

The API keys for Google Maps and Google Search can be optained from

Tags: Geocoding |Google Maps |Google Search |Hack |UK Post Codes

Add a comment
 | Link | Back to top | del.icio.us digg it furl reddit
Previous Next

© Eriginal Ltd 2011, all rights reserved