1
我有GPS数据,我正在尝试计算行程最远处的方位。我的数据是这样的:计算行程最远点的方位
Time Lat Long 18:11:25 -38.621449 142.931061 18:13:25 -38.62212 142.929871 18:15:33 -38.623333 142.92868 ... 23:16:26 -38.793068 142.827881 23:18:54 -38.795414 142.838516 23:23:02 -38.795803 142.839066 ... 09:59:49 -38.621532 142.930786
我试图计算起点(-38.621449 142.931061)和最远点(-38.793068,142.827881)之间的轴承。
我已经能够做到这一点通过我的剧本从电子表格手动提取2个位置,并计算轴承:
` bearing <- function(lat1,lon1,lat2,lon2){
lat1 <- angledim(lat1,"degrees","radians")
lon1 <- angledim(lon1,"degrees","radians")
lat2 <- angledim(lat2,"degrees","radians")
lon2 <- angledim(lon2,"degrees","radians")
dlon <- lon1 - lon2
theta <- atan2(cos(lat2)*sin(dlon),cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon))
theta <- angledim(theta,"radians","degrees")
theta <- (theta+360) %% 360
theta
}`
有没有计算这个无需通过无休止的电子表格会更简单的方法?
(提前道歉,如果事情不正确的格式,这是我的第一个问题!)
谢谢!