[GRASS-user] How to find a point on Earth d distance away from a given point?

Yuri Kanivetsky yuri.kanivetsky at gmail.com
Thu Sep 8 02:35:24 PDT 2016


Hi,

Sorry if this sort of questions are not discussed here. If so, I'd
appreciate it if you told me where to ask.

Given a point A (lat1, lng1) I need to find coordinates of point B
(lat2, lng2) d km away from point A.

This is basically what I want:

    http://math.stackexchange.com/questions/1026466/given-a-longitude-and-latitude-and-a-specified-distance-how-would-i-go-about-fi/1026501

But the person who answers seem to be using formula for colatitudes
(actually, the formulas seem to be identical, I don't see a
difference), and supposedly have a mistake in resulting forumla
(missing phi_a). And most importantly, I did just that (or so I
think), but it doesn't work.

I choose lat2 = lat1, dist = 10, for example, and then calculate lng2 like so:

    lng2 = lng1 + d(acos(
        (cos(dist / R) - sin(r(lat1)) * sin(r(lat1)))
        / cos(r(lat1)) * cos(r(lat1))
    ))

where R - radius of the Earth, d() converts radians to degrees, and
r() does the opposite.

Then put this all into original formula (from
http://www.movable-type.co.uk/scripts/latlong.html):

    d = acos(
        sin(r(lat1)) * sin(r(lat2))
        + cos(r(lat1)) * cos(r(lat2)) * cos(r(lng2 - lng1))
    ) * R

And get d <> 10.

What am I doing wrong? Your help is greatly appreciated.

You can experiment with it here, if you feel like it:
http://fiddle.jshell.net/LLh42xh5/3/ Click Run to rerun the script
after making changes.

Regards,
Yuri


More information about the grass-user mailing list