Checking postcodes
Created 2009-02-26T03:36:05.463Z, last edited 2009-02-26T04:11:19.875Z
Last time it seems that I managed to go all the way through Thursday thinking it was Wednesday. By the time I was convinced that it actually was Thursday it was far too late to put up the problem. Whoops!
This problem is something a little more practical, relevant to some things I have on this site and as a consequence more open ended. Free the postcode is a project to try to build a geo database of UK postcodes.
If you take a look at the database in Google Earth then it should become apparent that there are a number of data points that are clearly in the wrong places such as SK7 1NJ. Less obviously wrong is SW1A 0AA which is in amongst the NN codes rather than the other SW codes1.
The challenge is to write some code that will process the dataset and produce a list of post codes that are probably incorrect. The more useful you can make the program the better of course.
Some suggestions:
- A simple starting point would be to work out the centre of each group of postcodes (i.e. all of the BN, BR, SW etc.) and then just list those furthest away in each group.
- Find some contour data for the UK and list those that are in the sea.
- There are a large number of graph based algorithms that are suitable. For example, post codes areas don't overlap so you could try to draw contours around then and work out where overlaps occur.
- If your program uses more than one rule to determine validity it would useful to know which rules produced which parts of the output.
- Because the UK straddles the prime meridian it's easy to get the sign of the latitude wrong — which of the ones that you mark as incorrect would look more correct if you flip the sign of the latitude?
If this seems too much like hard work, then just having some programs available that do some statistical analysis of the results so far, e.g. maybe that lets us estimate how many outstanding postcodes there are in different areas, would be helpful.
- The data for display in Google Earth is available as a direct download. If you want the data in XML format then this is also for you.
- The data is also available as a text file.
© 2002-2025 Kirit & Tai Sælensminde. All forum posts are copyright their respective authors.
Licensed under a Creative Commons License. Non-commercial use is fine so long as you provide attribution.