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

2023-09-28Python开发问题
62

本文介绍了在给定点、方位角和距离的情况下计算 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 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11