Distances between UK postcodes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
starsol
Forum Newbie
Posts: 24
Joined: Thu Jul 31, 2003 8:30 am
Location: Norfolk, England.
Contact:

Distances between UK postcodes

Post by starsol »

I've seen a lot of website that have a feature to work out the distance between two UK postcodes. (For example on an estate agency website, you can search for houses within 50 miles of a certain postcode).

I imagine this works by having every UK postcode is stored in a database with a grid reference, and working out the distance 'as the crow flies' between the two grid reference points.

Does anyone know of anywhere that I could get hold of such a database? Also, can anyone advise on a function for working out the distance between two grid reference points?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Working out the distance is actually the easy part - it's a simple triangulation. The problem is getting the post codes in the first place - most of the large sites will subscribe to the Royal Mail Postcode Index, where they are issued complete and accurate listings with regular updates in a format they can import to their databases, etc.

Be warned - this is VERY expensive :(
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

starsol - I know someone who's site uses such a system - it costs around £1000/year. As for the maths, you need to use pythagoras. Look this up on google, if you've got minimal algebra skills it shouldn't be too much of a problem.

Mark
Post Reply