Implementation of Great Circle Destination formula?

1.5k views Asked by At

I am writing a Python program to generate some maps in Google Earth, I am using a colleague's script written in Perl and I came to a point where there is this Great Circle call:

@r = great_circle_destination($long, $lat, $bearing, $dist);

What is the equivalent for Python? Is there a module like this:

use Math::Trig ':great_cricle';
1

There are 1 answers

0
Lie Ryan On

I'm pretty sure there's no such thing in the standard library. I'm pretty sure there'd be a python GIS library that have similar functions, but there are many different ways to do this calculation depending on which model of the earth you uses (e.g. spherical earth or ellipsoid earth or something more complex), so you probably would want to check out the source code of the Perl module and translate that to python.

If you want to implement it yourself, you might want to look in this page for a formula for Destination point given distance and bearing from start point: http://www.movable-type.co.uk/scripts/latlong.html

It shouldn't be too difficult to translate that formula to python:

R = ... Radius of earth ...
def great_circle_destination(lon1, lat1, bearing, dist):
    lat2 = math.asin( math.sin(lat1)*math.cos(dist/R) + 
          math.cos(lat1)*math.sin(dist/R)*math.cos(bearing) )
    lon2 = lon1 + math.atan2(math.sin(bearing)*math.sin(dist/R)*math.cos(lat1), 
                 math.cos(dist/R)-math.sin(lat1)*math.sin(lat2)
    return lon2, lat2