我有一组以十进制表示的GPS坐标,我正在寻找一种方法来查找每个位置周围半径可变的圆内的坐标。
这里是一个示例,它是以坐标47,11
为中心,半径为1km
的圆形。
我需要的是查找圆形坐标的算法,这样我就可以将其用于我的kml文件中,并使用多边形。最好是用Python实现。
我有一组以十进制表示的GPS坐标,我正在寻找一种方法来查找每个位置周围半径可变的圆内的坐标。
这里是一个示例,它是以坐标47,11
为中心,半径为1km
的圆形。
我需要的是查找圆形坐标的算法,这样我就可以将其用于我的kml文件中,并使用多边形。最好是用Python实现。
另请参阅将距离添加到GPS坐标 ,以获取有关纬度/经度和短距离之间简单关系的信息。
这个有效:
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
在这里使用“起始点和距离给定的方位角的目标点”公式:
http://www.movable-type.co.uk/scripts/latlong.html
以您的中心点作为起点,将半径作为距离,并在0度至360度之间循环一些方位角。这将给您在圆上的点,并且可以在极地工作,因为它在所有地方使用大圆。
y = 0
开始,用 x = r
找到你的x
值。然后,通过角度 a
(以弧度为单位)绕原点旋转半径。你可以用 Xi = r * cos(a)
,Yi = r * sin(a)
找到圆上下一个点的坐标。重复最后的 2 * Pi / a
次即可。(AB) = D * Theta
,其中 Theta = 2 * sin(|AB| / 2)
。此外,很容易找到所有其他尺寸。