distance between zip codes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hjones21
Forum Newbie
Posts: 4
Joined: Mon Apr 24, 2006 3:33 pm

distance between zip codes

Post by hjones21 »

Does anyone know how i can determine the distance between zip codes.
So for example, right now i have a list of zip codes that get pulled from a mysql dbase upon the users entry.
I would like to put the distances between each zip code in miles .

Any ideas?

Thanks
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

You need a zipcode database (Canada isn't free, but I believe you can get the USA postal code database for free)...

The databases usually include latitude/longitude coordinates for a zipcode center.

Using these coordinates it's becomes quite trvial to calculate a great circle...aka the distance your after...

Poke around these forums, as I'm sure this question has been asked before and I recall someone having written a class which performs the calculation for you...which is easy to implement, but not trivial by any means...

Cheers :)
Post Reply