This will give you an approximation.  If you do some research and a little more math, you can come up with a more accurate number.

Since you have the lat/lon of two points, you can draw a right triangle and then get the distance of the hypotenuse, in degrees, and then multiple that by 69.11 (which is the number of miles in a degree according to this site:  http://wiki.answers.com/Q/How_many_miles_are_in_a_degree_of_longitude_or_latitude).

If we use 100,50 and 122,38 as the two zip code centers we get 22 and 12 as the distance in degrees of the two sides of a right triangle.  a^2 + b^2 = 628 (c^2), so c = 25.0599 degrees, which is 1,731.9 (rounded) miles.  If you take the cosines of the latitudes and average them, you will get a more accurate result.  If you don't your results will all be inaccurate to a varying degree, but you could still reliable compare distances.

Jason
Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)

On 9/12/2011 10:37 AM, Dan Goldberg wrote:
I am working on a dealer locator inside of Rbase and am trying to figure out how to calculate the distance, as a crow flies, between two postal codes.
 
I have downloaded the postal data that includes the postal code, city, state, and longitude/latitudes but am fuzzy on how to do the calculations.
 
I want to calculate every zipcode to its nearest dealer and put it in a table. I have searched the web and there are calculators but I they only do one zipcode at a time.
 
I was wondering if anyone has done something similar to this and have some pointers.
 
TIA
 
 
Dan Goldberg



Reply via email to