在给定点、方位角和距离的情况下计算 gps 坐标

2022-01-22 00:00:00 python coordinates gps bearing

问题描述

我有一个问题让我在某个项目中退缩了一段时间.

I have a problem which draws my back in some project for some time now.

我基本上是在寻找使用我编写的一些脚本绘制的 x、y 点来捕获多边形.lat, lon 是多边形的中心 GPS 线,我正在寻找它周围的多边形.

I'm basically looking to trap a polygon using x, y points drawn by some script I've written. lat, lon are the center GPS cords of the polygon and I'm looking for its surrounding polygon.

这是我在 python 中的代码的一部分:

here is a part of my code in python:

def getcords(lat, lon, dr, bearing):
    lat2=asin(sin(lat)*cos(dr)+cos(lat)*sin(dr)*cos(bearing))
    lon2=lon+atan2(sin(bearing)*sin(dr)*cos(lat),cos(dr)-sin(lat)*sin(lat2))
    return [lat2,lon2]

我的输入是这样的:

  • lat、lon - 以十进制度数给出.
  • dr - 是以英里为单位的距离除以地球的 -radius (=3958.82) 计算得出的角度
  • 轴承 - 0-360 度之间.

但是对于输入:

getcorsds1(42.189275, -76.85823, 0.5/3958.82, 30)

我得到输出:[-1.3485899508698462, -76.8576637627568],但是 [42.2516666666667, -76.8097222222222] 是正确的答案.

I get output: [-1.3485899508698462, -76.8576637627568], however [42.2516666666667, -76.8097222222222] is the right answer.

至于角距离,我只是用距离(英里)除以地球半径(=3958.82)来计算.

as for the angular distance, I calculate it simply by dividing the distance in miles by the earth's radius(=3958.82).

有人吗?


解决方案

你为什么不用 nice图书馆?

from geopy import Point
from geopy.distance import distance, VincentyDistance

# given: lat1, lon1, bearing, distMiles
lat2, lon2 = VincentyDistance(miles=distMiles).destination(Point(lat1, lon1), bearing)

对于 lat1、lon1、distMiles、bearing = 42.189275,-76.85823, 0.5, 30 它返回 42.1955489, -76.853359.

For lat1, lon1, distMiles, bearing = 42.189275,-76.85823, 0.5, 30 it returns 42.1955489, -76.853359.

相关文章