As we all know the full postcode database with all latitude and longitude information is Copyright to Royal Mail. This is annoying. I know there are loads of databases out there which claim to be the full dataset and there are loads of API’s which will geocode UK postcodes etc. In the past we have used an awesome service called PostcodeAnywhere which does a great job of address lookup and validation… but it’s a paid service… obviously they have to make money somehow! I have also played with Google API etc. I also think that someone released a dataset on Wikileaks but if I remember rightly this was partial postcodes (only contains the first part of the postcode e.g. TS19).
I was chatting to Alex Akass on skype the other day and he pointed me to the Ordnance Survey website who have just released a full set of UK postcodes in a database as recent as February 2012! The service, called Code-Point Open (ordnancesurvey.co.uk) contains 2,993,351 rows. This data also looks to be available on the new data.gov.org beta site under the same name Code-Point Open (data.gov.uk).
The data comes in CSV files to split the data up. I created a quick PHP script that looped through these files and put all the postcodes into one database table. All looks good.
This got me thinking. The database comes with ‘Postcode’, ‘Eastings’ & ‘Northings’ columns. There must be something you can run Eastings and Northings through to get the latitude and longitude. I did a quick Google and found a post by a guy called samjudson on this forum.
I searched for my postcode in the database and then ran the Northings and Eastings through this function to get the latitude and longitude. I used itouchmap.com to load this data on the map and compared it with the pointer that got shown on the map when I inputted my postcodes directly. They were very close, close enough to be useful I think.
So what I was thinking, was I could add the conversion function to my php script and whilst I am looping through the csv files I could also add the latitude and longitude and I will end up with a current table with full UK postcode, Eastings, Northings, Latitude & Longitude.
Would welcome thoughts…
Here you can get one that is up-to-date comes regular data updates and with radius and distance scripts and it is the only I found that contains Northern Ireland data.
http://www.postcode-distance.com/postcode-database-uk
You can purchase a database from me with all UK post codes, it comes with a MySQL database relation and some php classes which allow you to perform euclidean distance computations from street to street (calculate distances with ease) http://www.nullox.com/resources/uk-post-code-system-data/
Did you complete this work?
There is a paid database that contains all the UK postcodes including northern Ireland plus their longitude / latitude.
http://www.postcode-distance.com/postcode-database-uk
Database is updated twice yearly and customers have free access to updated database.
Hey James, check out this post:
http://www.deepbluesky.com/blog/-/converting-os-coodinates-into-longitude-latitude_7/
You could very well make your own chunk database if you leave a long-running process going on some micro EC2 instance. It would take a while, but you’d get there 😉
Sadly, the OS codepoint open dataset is not UK wide, because for some historical quirk, there is a different organisation that does the official mapping of Northern Ireland (OSNI), and they haven’t released their equivalent datasets yet.
I had an interesting reply on twitter from @inpocketdev pointing me to http://www.jstott.me.uk/phpcoord/ & his API at http://postcodelookups.co.uk
https://twitter.com/#!/inpocketdev/status/185015713562497024
https://twitter.com/#!/inpocketdev/status/185019631331852288