0

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

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

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

use Math::Trig ':great_cricle';
4

1 回答 1

2

我很确定标准库中没有这样的东西。我很确定会有一个具有类似功能的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
于 2013-09-02T21:02:44.447 回答