【问题标题】:How to calculate diametrically opposite in coordinates(lat, lon) where -90<lat<90 and -180<lon<180如何在 -90<lat<90 和 -180<lon<180 的坐标(纬度,经度)中计算截然相反
【发布时间】:2021-07-19 13:32:52
【问题描述】:

给定一个坐标点 X=(lat, lon) 和一个圆心 C=(lat_center, lon_center) 我想计算点 X 的截然相反的坐标(假设 X 在圆心的圆内是 C)。

例如,如果 C=(45.9, 180),则与 X=(45.9, -179) 截然相反的应该是 (45.9, 179)。

以下函数是一个近似值,但不能解决纬度在 (-90, 90) 和经度 (-180, 180) 之间的问题。

def f(lat, lon, center):
  lat_center = center[0]
  lon_center = center[1]
  dist_lon = np.abs(lon - lon_center) if np.abs(lon - lon_center)<180 else 360 - np.abs(lon - lon_center)
  dist_lat = np.abs(lat - lat_center) if np.abs(lat - lat_center)<180 else 360 - np.abs(lat - lat_center)
  lon_op = lon_center + dist_lon if lon_center + dist_lon != lon else lon_center - dist_lon
  lat_op = lat_center + dist_lat if lat_center + dist_lat != lat else lat_center - dist_lat
  return np.round(lat_op, 2), np.round(lon_op, 2)

【问题讨论】:

  • 您希望得到的结果有多精确,C 与 X 的距离有多远?最好的方法:寻找大地测量库:你计算 X 和 C 之间的大地测量的距离和方向,然后你应用到 C 的方向和距离,所以你得到 Y。在较短的距离上,你可以使用其他技巧(只是球体或也只是笛卡尔坐标)
  • 什么是latlon,角度还是坐标?
  • 纬度和经度是坐标

标签: python math coordinates


【解决方案1】:

将点到圆心的路径加到圆坐标上?

C=(0, 0) X=(1, 1)

C - X = (-1, -1) # 从 X > C 开始的(最终 - 初始)路径

C + (-1, -1) = (-1,-1)

【讨论】:

【解决方案2】:

使用来自this page 的公式和脚本,我们可以:

1 ) 计算从 X 到 C 的方位

θ = atan2( sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ )
where   
φ1,λ1 is the start point, φ2,λ2 the end point (Δλ is the difference in longitude)

2 ) 计算 X 到 C 的距离

a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c
where   φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km);
note that angles need to be in radians to pass to trig functions!

3 ) 使用相同的方位和加倍的距离找到Destination point given distance and bearing from start point

φ2 = asin( sin φ1 ⋅ cos δ + cos φ1 ⋅ sin δ ⋅ cos θ )
λ2 = λ1 + atan2( sin θ ⋅ sin δ ⋅ cos φ1, cos δ − sin φ1 ⋅ sin φ2 )
where   φ is latitude, λ is longitude, θ is the bearing (clockwise from north),
δ is the angular distance d/R; d being the distance travelled, R the earth’s radius

(作为变体 - 获取从 C 到 X 的距离和方位,然后使用 θ+Pi 以相同距离(不加倍)找到相反方向的点)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 2013-04-22
    • 2010-10-16
    • 1970-01-01
    • 2013-08-19
    • 2013-02-09
    • 2021-11-28
    相关资源
    最近更新 更多