I would like to approximate the distance of a line segment from a reference point on the map (coordinates are gives as lat/lon).

In the Cartesian coordinate system I would simply find the closest point of the line segment to the reference point using the dot product and calculate the distance.

I am new to working with geo-coordinates, and from what I have learnt, segments are called great circles on the Earth's surface. This site gives a clear formula for calculating what I would like (which is I think called the cross-track distance). However it seems an overkill for what I want to do. Firstly, I am interested in shorter distances only, maximum a few hundred kilometers (say 700 km). Second, I can do with an approximate value (say maximum 2-3% error). Third, I want the calculation as quick as possible, and the exact formula contains around 20 trig calculations.

I would need something similar to equirectangular approximation:

x = (lon2-lon1) * cos((lat1+lat2)/2)
y = lat2-lat1 
d = sqrt(x*x + y*y) * R

Is there a way to generalize the above formula for point-segment distances? Or, alternatively, is there a handy approximation to find out the distance of a point and a great circle for small-to-mid distances with reasonable accuracy?

  • 2
    A solution that involves only five trig functions and is accurate to about 0.3% or better is given at gis.stackexchange.com/questions/81845/…. An approximation involving only two trig functions is given at gis.stackexchange.com/a/30037/664.
    – whuber
    Commented Jan 27, 2014 at 16:38
  • 2
    Welcome to GIS.SE. Dare i say, one of the best-prepared questions from a newcomer.
    – Martin F
    Commented Jan 27, 2014 at 17:00
  • @whuber: thanks, I get it. I think I'll go with the second approach, ie. map the points to the Euclidean plane using the displacements given in your answer.
    – BKE
    Commented Jan 28, 2014 at 9:52
  • @whuber, maybe I am missing something, but boths answers linked answer close, but not the same question. Here is the actual answer with pretty pictures: stackoverflow.com/questions/32771458/… Commented Mar 4, 2017 at 18:28


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.