How to compute great circle distances (given lat and long) in MS
am 31.01.2008 03:42:33 von velocityinc
I would like to compute the great circle distance between 2
destinations with the lat and long information provided.
Any ideas on the formula to be used as an expression, and if an
analysis add-in is needed.
Thank you in advance.
BR
Velocity
Re: How to compute great circle distances (given lat and long) in MS Access
am 31.01.2008 04:25:23 von Tom van Stiphout
On Wed, 30 Jan 2008 18:42:33 -0800 (PST), velocityinc@gmail.com wrote:
Find a description of the algorithm online. You'll see it's fairly
basic geometry, and VBA will be able to handle it without any add-ins
(though if you didn't care for writing the code, that's one way you
could buy it).
-Tom.
>I would like to compute the great circle distance between 2
>destinations with the lat and long information provided.
>
>Any ideas on the formula to be used as an expression, and if an
>analysis add-in is needed.
>
>Thank you in advance.
>
>BR
>
>Velocity
Re: How to compute great circle distances (given lat and long) in MS
am 31.01.2008 12:49:46 von velocityinc
On Jan 30, 10:25=A0pm, Tom van Stiphout wrote:
> On Wed, 30 Jan 2008 18:42:33 -0800 (PST), velocity...@gmail.com wrote:
>
> Find a description of the algorithm online. You'll see it's fairly
> basic geometry, and VBA will be able to handle it without any add-ins
> (though if you didn't care for writing the code, that's one way you
> could buy it).
>
> -Tom.
>
> >I would like to compute the great circle distance between 2
> >destinations with the lat and long information provided.
>
> >Any ideas on the formula to be used as an expression, and if an
> >analysis add-in is needed.
>
> >Thank you in advance.
>
> >BR
>
> >Velocity
Does this GCD code work well? How can error handling be incorporated.
Function LatLonDistance(Lat1 As Double, Lon1 As Double, Lat2 As
Double, Lon2
As Double) As Double
Const Pi =3D 3.141592654
Const DegToStatMiles =3D 3958.754
Dim rLat1 As Double, rLon1 As Double, rLat2 As Double, rLon2 As
Double, X As
Double
rLat1 =3D Pi * Lat1 / 180
rLon1 =3D Pi * Lon1 / 180
rLat2 =3D Pi * Lat2 / 180
rLon2 =3D Pi * Lon2 / 180
X =3D Sin(rLat1) * Sin(rLat2) + Cos(rLat1) * Cos(rLat2) * Cos(rLon1 -
rLon2)
If X >=3D 1 Then
LatLonDistance =3D 0 'Error condition, I assume that the two points
are
the same
Else
LatLonDistance =3D DegToStatMiles * (Atn(-X / Sqr(-X * X + 1)) + 2
*
Atn(1))
End If
End Function