Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1250
  • Last Modified:

How to calculate distance between two zip codes?

Do you have a routine that calculates the distance between two zip code?

If you don't have a routine, an algorithm that I can use to calculate the distance between zip codes.

On yahoo maps if you enter in the starting and ending zip codes it will display the distance in miles between the zip code.  This is an example of the functionality I am looking for.

Languages: asp, javascript,  vb - dll
0
swansonplace
Asked:
swansonplace
  • 5
  • 3
  • 2
  • +2
5 Solutions
 
golfDoctorCommented:
this is not possible, unless you have a Google/Yahoo/etc. database
0
 
golfDoctorCommented:
There is not such "algorithm " without the data, which you don't have or have access to.
0
 
DxpertCommented:
Hello there,

To calculated distances between zipcodes, you will need to have a database with every zipcode in the US, plus Longitude and Latitude for each.

http://blog.devspan.com/2005/10/efficiently-calculating-zip-code.html
http://www.4guysfromrolla.com/webtech/010500-1.shtml
http://www.zipinfo.com/products/z5ll/z5ll.htm
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mkulonCommented:
Hello,

I suggest that you
1 - sign up for Google Maps API (http://www.google.com/apis/maps/) - it's free & easy to use!
2 - use PHP/ASP/whatever to lookup the longitude & latitude of your ZIP code OR __Street Address__ via their API - Google has a nice How-to section, i can also help you further if you get stuck
3 - Use Great Circle Distance Formula:
IF YOUR TRIG functions are in degrees:
    3963.0 * arccos[sin(lat1) *  sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)]
OR IF YOUR TRIG functions are in radians:
    3963.0 * arccos[sin(lat1/57.2958) * sin(lat2/57.2958) + cos(lat1/57.2958) * cos(lat2/57.2958) *  cos(lon2/57.2958 -lon1/57.2958)]
0
 
bugs021997Commented:
@swansonplace

I would agree and go with @mkulon
0
 
bugs021997Commented:
I forgot to mention which gives a detailed explanation for calculating distance between postal codes...

http://authors.aspalliance.com/tmorford/distance/calculate_Zip_1.asp
0
 
swansonplaceAuthor Commented:
I really liked the google maps api but it is only available to wbsites that are generally accessible to consumers without charge.  My is an internal website that is used for business.  

I am corrected. I do not need the radius, but the driving distance from two zip codes.  Do you know how I could get this.
0
 
bugs021997Commented:
Do whatever you want until and unless you interact with some of the biggies like YAHOO/GOOGLE/ZIPCODES etc who have built such kind of data you won't be able to get through.

If your's is a biz website wherein you are charging your customers then i would suggest you can goahead with GOOGLE's enterprise license and start charging your consumers... http://www.google.com/enterprise/maps/
0
 
swansonplaceAuthor Commented:
Bugs,

I didn't understand the last statement:

Do whatever you want until and unless you interact with some of the biggies like YAHOO/GOOGLE/ZIPCODES etc who have built such kind of data you won't be able to get through.

Are you saying that the biggies servers are so bogged down, that I won't be able to get in.

swansonplace
0
 
bugs021997Commented:
@swansonplace

Pardon my typing....

What i meant was the only way to get this kind of detail is by accessing the database of the biggies like YAHOO/GOOGLE or other providers using their API's which come both free as well as paid. Depending upon the nature of your website you can select the services offered and start working.

I guess thats what @golfdoctor and @mkulon, were spot on and specified at the begining of this thread.
0
 
swansonplaceAuthor Commented:
Just in case anyone else is looking for the same issue, I have found but not test the following open source code.  It doesn't do what we have been discussing on this thread, however, if you are looking for a low cost way to help your users get all zipcodes within a certain radius give this one a shot.
http://www.filedudes.com/Zipoid-download-35684.html

Also, it may be cost prohibitive for my needs now, but if someone else  is also in the same situation and has the time to fiddle around with it, I found out the US government gives away the zip code and latitude longtitude information needed.  All you would have to do is import it into a file, and execute the zip logic that you like.

http://authors.aspalliance.com/tmorford/distance/calculate_Zip_1.asp
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now