Calculating distances between post codes

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
P

Paul Aspinall

Hi
Can anyone recommend a suitable way of calculating distances between UK post
codes??

Many websites do this, and I'm wondering if there is some standard code, and
where the reference DB comes from?

Any help/advice appreciated

Thanks
 
Do you mean a simple projection calculation? Then all you need is the
long/lat. I believe Hopeweiser (among others) will sell you this for a
price... but note that it is around 2.3m rows deep including all
levels. The formala for distance from two geo-codes isn't pretty, but
is reasonably easy (will post if you need it).

If you mean road distance, that is a *whole* other thing, and requires
highly specialised software (MapPoint [desktop/WS], MapQuest, etc).

If you don't want to do the calcs yourself, then look into some of the
web-services; I googled "webservice uk postcode distance" and got a
few hits. As another thought - for a web-page, note that you can use
the google-maps API to do a lot of things like this, as long as your
intent suits client-side processing (i.e. nothing extreme like
calculating a distance triangle for a few thousand nodes).

Marc
 
Can anyone recommend a suitable way of calculating distances between UK
post codes??

For that, you need to get hold of the longitude and latitude of each
postcode. This is available from various sources, notably (as you might
imagine!) the Post Office, but it's quite expensive. There are upwards of 2
million postcodes in the UK, so you'll need some sort of RDBMS to hold the
data.

Armed with this, it's simple trigonometry - Pythagorus' theorem, and all
that... 10 years or so ago I did a contract for a mystery shopping company
which had precisely this requirement - i.e. find me the nearest researchers
to a certain Pizza Hut etc... Stored the data in SQL Server and built a
simple stored procedure which accepted the two postcodes as parameters and
returned the distance between them. I might even have it somewhere, but it's
really a five-minute job to write the T-SQL...

Quite a few companies offer access to the postcode database via webservices
so that companies can integrate address lookup and validation into their
apps - this seems pretty much what you're looking for:
http://www.postcodeanywhere.co.uk/developers/documentation/uk/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top