Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / January 2008

Tip: Looking for answers? Try searching our database.

How to compute great circle distances (given lat and long) in MS     Access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
velocityinc@gmail.com - 31 Jan 2008 02:42 GMT
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
Tom van Stiphout - 31 Jan 2008 03:25 GMT
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.
[quoted text clipped - 7 lines]
>
>Velocity
velocityinc@gmail.com - 31 Jan 2008 11:49 GMT
> 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
[quoted text clipped - 14 lines]
>
> >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 = 3.141592654
Const DegToStatMiles = 3958.754
Dim rLat1 As Double, rLon1 As Double, rLat2 As Double, rLon2 As
Double, X As
Double
rLat1 = Pi * Lat1 / 180
rLon1 = Pi * Lon1 / 180
rLat2 = Pi * Lat2 / 180
rLon2 = Pi * Lon2 / 180
X = Sin(rLat1) * Sin(rLat2) + Cos(rLat1) * Cos(rLat2) * Cos(rLon1 -
rLon2)
If X >= 1 Then
   LatLonDistance = 0 'Error condition, I assume that the two points
are
the same
Else
   LatLonDistance = DegToStatMiles * (Atn(-X / Sqr(-X * X + 1)) + 2
*
Atn(1))
End If
End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.