本文介绍了线上获得n点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一条由起点和终点坐标定义的线,那么在考虑地球曲率的情况下,如何在该线上获得n个等距的点?

If I have a line defined by a start and end coordinates, how do I get n equally spaced points on that line, taking the curvature of the earth into account?

我正在寻找一种算法和/或实现此功能的python库.

I'm looking for an algorithm, and/or a python library that implements this.

推荐答案

使用 geographiclib , python的GeographicLib实现,我能够做到这一点:

Using geographiclib, a python implementation of GeographicLib, I was able to do this:

from geographiclib.geodesic import Geodesic

number_points = 10

gd = Geodesic.WGS84.Inverse(35, 0, 35, 90)
line = Geodesic.WGS84.Line(gd['lat1'], gd['lon1'], gd['azi1'])

for i in range(number_points + 1):
    point = line.Position(gd['s12'] / number_points * i)
    print((point['lat2'], point['lon2']))

输出:

(35.0, -7.40353472481637e-21)
(38.29044006500327, 7.8252809205988445)
(41.01134777655358, 16.322054184499173)
(43.056180665524245, 25.451710440063902)
(44.328942450747135, 35.08494460239694)
(44.76147256654079, 45.00000000000001)
(44.328942450747135, 54.91505539760305)
(43.05618066552424, 64.54828955993611)
(41.01134777655356, 73.67794581550085)
(38.290440065003274, 82.17471907940114)
(34.99999999999999, 90.0

这篇关于线上获得n点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 23:41