Postcodes revisited

Rob Brookes' Blog - MRMap and Communications Info

Postcodes revisited

Postby Rob_Brookes » Sun Mar 13, 2011 6:34 pm

Some time ago I wrote a small application to convert postcodes to a grid reference, Lat/Long etc. In order to work, it needed an internet connection which isn't always available. To get around this I downloaded the Ordnance Survey Code Point database from their website where it's available free of charge.
https://www.ordnancesurvey.co.uk/opendatadownload/products.html

This quite handy file contains over 1.7 million postcodes with their geographic location accurate to around 100 metres. Whilst I was at it, I added a second database, again free from OS, which contains the entire 1:50,000 gazetteer of place names again with sufficient geo referenced information to place a marker at the somewhat arbitrary point that OS determing to be the location in question. In the case of towns and villages, this isn't necessarily the centre by any means but will always be close.

Using another free piece of code, SQLite 3, I lumped all the databases into a stand-alone file which can be searched using simple SQL queries. The beauty of using SQLite is that it runs on your own computer and not on a remote server. It's embedded with the application and do can be moved to any computer without needing to set up mySQL or SQL Server and the like. It's simplicity in use is evidenced by the fact that I could actually use it in the first place!

The result was a stand alone application which wouldn't in practice need an internet connection, (my program uses Google Maps for speed of development but I've now incorporated the normal 1:25k OS maps that live in the MRMap 'Maps' folder.)

Image

Because I've used Google Maps here, the image shows both the over head map view of Langdale's base and also the StreetView of the front doors. There are advantages to using Google in this respect but the intention was this time to produce an application which didn't require any connection to the internet. The Google Maps window was replaced by one using ordinary map tiles and this means it's now entirely stand alone.

The Google version of the program is about 145MB is size, almost all of this being the combined postcode and gazetteer database. If you switch to using the 1:25k maps then this rockets up to over 11GB of course but as I already have these maps in Dave's MRMap application, I certainly don't intend to load them twice so the program remains at around an additional 145MB required to run it and I just direct it to the relevent MRMap folder.

Anyone with an interest in writing simple code is recommended to have a trawl through the stuff on the OS website as there's a lot of potentially useful files on there apart from the more obvious maps. Whilst I would be the first to say that very few mountains have postcodes, there are teams who get their casualty location information in this way or who need to convert a postcode from some remote island off shore into a lat/long or grid reference that will enable reliable navigation. The gazetteer information is limited to those place names that can be found on a 1:50k map but this is enough for all but the very smallest hamlets and will locate most rivers and reasonably well known geographical features. If I enter 'Kend' instead of 'Kendal' then the program returns slightly over 1000 results in about one and a half seconds so it's quite quick. This is down to using SQL of course.
If anyone wants any further details of how it's done or how to set up the database, let me know and I'll do what I can.
Rob_Brookes
 
Posts: 191
Joined: Mon Jul 14, 2008 10:37 am
Location: Langdale Ambleside MRT

Return to Robs Blog

cron