Dan,

You can Google various formulas for determining distance as they would be
done in JavaScript or Excel or other languages, although it will not be
driving or walking or biking distance, but a great-circle arc distance on
the globe. You can probably imitate one of these with R:BASE functions, and
create a stored procedure that would take four values for lat1, long1, lat2
and long2 and do the calculations.

One UK Excel formula is:

=ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371

( 6371 km is the mean radius of the planet. You might want to convert that
constant to miles.)

Bill

On Mon, Sep 12, 2011 at 10:37 AM, Dan Goldberg <[email protected]> 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