如何解决在半径上生成随机的GPS点
有没有一种方法可以在给定半径的2个点之间生成随机点? 正如您在我的图形中看到的:A点和B点是已知的。 r也是已知的。我正在寻找一种在G和F之间生成点1,2,3的方法。我没有G和F点。拥有这些G和F点不是必须的。我以这些观点以某种方式定义了范围。例如,点1、2、3之间的给定距离可以是这样的定义。也就是说,在半径为5 km的半径上的任意点之间具有已知方位。是否有解决方案或方法? 提前非常感谢您!
解决方法
经过一些研究,我使用了该解决方案。 我希望其他人会发现这很有趣。
points_on_a_circle <- function(p1,p2,rb_wgs84,km_distance){
LatDec = p1[2]
LonDec = p1[1]
b <- geosphere::bearingRhumb(p1,p2)
Km = km_distance
ER <- 6371 #Mean Earth radius in kilometers. Change this to 3959 and you will have your function working in miles.
AngDeg <- seq((b - 40),(b + 40)) #angles in degrees / Set G and F borders
Lat1Rad <- LatDec*(pi/180)#Latitude of the center of the circle in radians
Lon1Rad <- LonDec*(pi/180)#Longitude of the center of the circle in radians
AngRad <- AngDeg*(pi/180)#angles in radians
Lat2Rad <- asin(sin(Lat1Rad)*cos(Km/ER) + cos(Lat1Rad)*sin(Km/ER)*cos(AngRad)) #Latitude of each point of the circle rearding to angle in radians
Lon2Rad <- Lon1Rad + atan2(sin(AngRad)*sin(Km/ER)*cos(Lat1Rad),cos(Km/ER) - sin(Lat1Rad)*sin(Lat2Rad))#Longitude of each point of the circle rearding to angle in radians
Lat2Deg <- Lat2Rad*(180/pi)#Latitude of each point of the circle rearding to angle in degrees (conversion of radians to degrees deg = rad*(180/pi) )
Lon2Deg <- Lon2Rad*(180/pi)#Longitude of each point of the circle rearding to angle in degrees (conversion of radians to degrees deg = rad*(180/pi) )
point_on_circle <- cbind(Lon2Deg,Lat2Deg)
return(point_on_circle)
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。