FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


algorithm to determine distance from lat/long





lightworker88
Does anyone know the algorithm for determining the geographic distance between two points on Earth's surface given only their latitudes and longitudes. (I believe a number of networking sites already use it to find "distance from you" as some of them describe it.)

I believe it would be like this:

    change in angle for latitude and for longitude
    chord length for latitude and for longitude (right angle between them)
    chord length between the points (via Pythagorean theorem)
    arc length between the points (the value desired)


A chord is the line segment between the endpoints of an arc.
kelseymh
lightworker88 wrote:
Does anyone know the algorithm for determining the geographic distance between two points on Earth's surface given only their latitudes and longitudes. (I believe a number of networking sites already use it to find "distance from you" as some of them describe it.)

I believe it would be like this:

    change in angle for latitude and for longitude
    chord length for latitude and for longitude (right angle between them)
    chord length between the points (via Pythagorean theorem)
    arc length between the points (the value desired)


A chord is the line segment between the endpoints of an arc.


You can't use the two changes in angle independently, nor (in general) can you use the Pythagorean theorem, because spherical geometry is not Euclidean. The arc length along a line of latitude varies as a function of that latitude itself: L = r * cos(lat) *d(long). Taking that into account, your procedure is a good approximation for nearby points, but not for long distances.

See https://en.wikipedia.org/wiki/Geographical_distance and https://en.wikipedia.org/wiki/Great-circle_distance for full discussion.
lightworker88
Thanks, kelseymh

I read the two articles but did not find any examples, although the second supposedly has one. Do you know of any other explanations?

I would think we could convert to (x,y,z) coordinates for both, take the chord length between them, and get the angle from that.
kelseymh
lightworker88 wrote:
Thanks, kelseymh

I read the two articles but did not find any examples, although the second supposedly has one. Do you know of any other explanations?

I would think we could convert to (x,y,z) coordinates for both, take the chord length between them, and get the angle from that.


Yes, I think you could. Making the simplifying assumption of a sphere, you could convert lat/long/radius to (x,y,z) for the two points, get the chord length sqrt(Dx^2+Dy^2+Dz^2), then map that back to the corresponding arc length.

You may be limited by round-off issues. Since the Earth's radius is so large, your coordinates will be large, and the squared differences may accumulate inaccuracies.
Related topics
Reply to topic    Frihost Forum Index -> Science -> Basics

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.