根据点,方位和距离计算GPS坐标 [英] calculating a gps coordinate given a point, bearing and distance
问题描述
我基本上想用一些脚本绘制的x,y点来捕捉多边形我写了。
lat1,lon1是多边形的中心gps线,im正在寻找其周围的多边形。
这里是我在python中的一部分代码:
def getcords(lat1,lon1,dr,bearing):
lat2 = asin(sin (lat1)* cos(dr)+ cos(lat1)* sin(dr)* cos(方位))
lon2 = lon1 + atan2(sin(方位)* sin(dr)* cos(lat1),cos (dr)-sin(lat1)* sin(lat2))
return [lat2,lon2]
我的输入如下所示:
lat1,lon1 - 以十进制度数给出。
-dr是通过用距离除以地球的距离(= 3958.82)
-在0-360度之间所得到的角度计算出的角度。
<但是对于输入getcorsds1(42.189275,-76.85823,0.5 / 3958.82,30)
i获得[-1.3485899508698462,-76.8576637627568],然而[42.2516666666667,-76.8097222222222]是正确的答案。
至于角距离,我简单地用距离除以地球距离(= 3958.82)来计算。 b
$ b
有人吗?
为什么不使用 nice libraries ?
from geopy import从geopy.distance中指向
输入距离,VincentyDistance
#给定:lat1,lon1,轴承,distMiles
lat2,lon2 = VincentyDistance(miles = distMiles).destination(Point(lat1,lon1),bearing)
对于lat1,lon1,distMiles,方位= 42.189275,-76.8582 3,0.5,30它返回42.1955489,-76.853359。
I have a problem which draws my back in some project for some time now.
Im basically looking to trap a polygon using x,y points drawn by some script ive written. lat1,lon1 are the center gps cords of the polygon and im looking for its surrounding polygon.
here is a part of my code in python:
def getcords(lat1,lon1,dr,bearing): lat2=asin(sin(lat1)*cos(dr)+cos(lat1)*sin(dr)*cos(bearing)) lon2=lon1+atan2(sin(bearing)*sin(dr)*cos(lat1),cos(dr)-sin(lat1)*sin(lat2)) return [lat2,lon2]
my input goes like this: lat1,lon1 - are given in decimal degrees. -dr is the angular computed by dividing the distance in miles by the earth's -raiuds(=3958.82) -bearing between 0-360 degrees.
however for the input getcorsds1(42.189275,-76.85823,0.5/3958.82,30) i get [-1.3485899508698462, -76.8576637627568], however [42.2516666666667,-76.8097222222222] is the right answer.
as for the angular distance i calculate it simply by dividing the distance in miles by the earth's raiuds(=3958.82).
anybody?
Why don't you use nice libraries?
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)
For lat1, lon1, distMiles, bearing = 42.189275,-76.85823, 0.5, 30 it returns 42.1955489, -76.853359.
这篇关于根据点,方位和距离计算GPS坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!