calculating a gps coordinate given a point, bearing and distance(在给定点、方位角和距离的情况下计算 gps 坐标)
问题描述
我有一个问题让我在某个项目中退缩了一段时间.
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.
这篇关于在给定点、方位角和距离的情况下计算 gps 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在给定点、方位角和距离的情况下计算 gps 坐标
基础教程推荐
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
