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
}`
有沒有計算這個無需通過無休止的電子表格會更簡單的方法?
(提前道歉,如果事情不正確的格式,這是我的第一個問題!)
謝謝!