Python的Great Circle Destination公式

时间:2013-09-02 20:33:52

标签: python-2.7 great-circle

我正在编写一个Python程序来在Google Earth中生成一些地图,我正在使用用Perl编写的同事脚本,我来到了这个Great Circle调用的地方:

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

Python的等价物是什么?有这样的模块:

use Math::Trig ':great_cricle';

1 个答案:

答案 0 :(得分:1)

我很确定标准库中没有这样的东西。我很确定会有一个具有类似功能的python GIS库,但是根据你使用的地球模型(例如球形地球或椭圆形地球或更复杂的东西),有许多不同的方法可以进行这种计算,所以你可能想查看Perl模块的源代码并将其转换为python。

如果您想自己实施,可能需要在此页面中查找目标点给定距离的公式,并从起点开始承担:http://www.movable-type.co.uk/scripts/latlong.html

将该公式转换为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