python:在某个GPS位置周围寻找围绕GPS坐标的优雅方式

otm*_*ger 7 python math gps dictionary coordinates

我有一组十进制表示法的GPS坐标,我正在寻找一种方法来找到每个位置周围可变半径的圆坐标.

这是我需要的一个例子.它是一个1km围绕坐标的半径圆47,11.

我需要的是找到圆的坐标算法,所以我可以使用多边形在我的kml文件中使用它.理想的python.

有任何想法吗?

Sté*_*ane 7

另请参阅为GPS坐标添加距离,以获得 lat/lon和短距离之间的简单关系.

这工作:

import math

# inputs
radius = 1000.0 # m - the following code is an approximation that stays reasonably accurate for distances < 100km
centerLat = 30.0 # latitude of circle center, decimal degrees
centerLon = -100.0 # Longitude of circle center, decimal degrees

# parameters
N = 10 # number of discrete sample points to be generated along the circle

# generate points
circlePoints = []
for k in xrange(N):
    # compute
    angle = math.pi*2*k/N
    dx = radius*math.cos(angle)
    dy = radius*math.sin(angle)
    point = {}
    point['lat']=centerLat + (180/math.pi)*(dy/6378137)
    point['lon']=centerLon + (180/math.pi)*(dx/6378137)/math.cos(centerLat*math.pi/180)
    # add to list
    circlePoints.append(point)

print circlePoints
Run Code Online (Sandbox Code Playgroud)

  • 不,这种近似是非常实用的,但你可以看到有一个1/cos(lat)项,所以它在极点发散.此外,它仅适用于10-100km以下的相对距离. (2认同)

Spa*_*man 6

在此处使用"目标点给定距离和从起点开始承载"的公式:

http://www.movable-type.co.uk/scripts/latlong.html

将您的中心点作为起点,将您的半径作为距离,并在0度到360度的多个轴承上循环.这将给你一个圆圈上的点,并将在极地工作,因为它到处使用大圆圈.