计算一个GPS位置与所有其他位置之间的距离

时间:2015-04-10 06:45:25

标签: r gps

我需要计算不同GPS位置之间的距离来观察蜥蜴的运动,我想知道它们何时开始和停止移动。所以我需要计算从一个位置到所有其他位置的距离。

这是一只蜥蜴一天前3小时的输出量:

structure(list(Date_Adelaide = structure(c(1L, 1L, 1L, 1L, 1L
), .Label = "20/09/2014", class = "factor"), Time_Adelaide = structure(c(9L, 
15L, 10L, 2L, 14L), .Label = c(" 0:00:00", " 0:10:00", " 0:20:00", 
" 0:30:00", " 0:40:00", " 0:50:00", " 1:00:00", " 1:10:00", " 1:20:00", 
" 1:30:00", " 1:40:00", " 1:50:00", " 2:00:00", " 2:10:00", " 2:20:00", 
" 2:30:00", " 2:40:00", " 2:50:00"), class = "factor"), Site = c(1L, 
1L, 1L, 1L, 1L), Lizard = c(20380L, 20380L, 20380L, 20380L, 20380L
), Sex = c(1L, 1L, 1L, 1L, 1L), Longitude = c(139.30833, 139.30909, 
139.30888, 139.30878, 139.30895), Latitude = c(-33.88866, -33.88835, 
-33.88844, -33.88856, -33.88838), Altitude = c(94L, 184L, 172L, 
204L, 174L), Satellites = c(4L, 4L, 4L, 5L, 4L), HDOP = c(2.8, 
4.4, 3.2, 3.4, 4.2), Date_Time_Adelaide = structure(c(9L, 15L, 
10L, 2L, 14L), .Label = c("20/09/2014 00:00", "20/09/2014 00:10", 
"20/09/2014 00:20", "20/09/2014 00:30", "20/09/2014 00:40", "20/09/2014 00:50", 
"20/09/2014 01:00", "20/09/2014 01:10", "20/09/2014 01:20", "20/09/2014 01:30", 
"20/09/2014 01:40", "20/09/2014 01:50", "20/09/2014 02:00", "20/09/2014 02:10", 
"20/09/2014 02:20", "20/09/2014 02:30", "20/09/2014 02:40", "20/09/2014 02:50"
), class = "factor"), Date_Time_Adelaide_DHM = structure(c(9L, 
15L, 10L, 2L, 14L), .Label = c("20/09/2014 00:00", "20/09/2014 00:10", 
"20/09/2014 00:20", "20/09/2014 00:30", "20/09/2014 00:40", "20/09/2014 00:50", 
"20/09/2014 01:00", "20/09/2014 01:10", "20/09/2014 01:20", "20/09/2014 01:30", 
"20/09/2014 01:40", "20/09/2014 01:50", "20/09/2014 02:00", "20/09/2014 02:10", 
"20/09/2014 02:20", "20/09/2014 02:30", "20/09/2014 02:40", "20/09/2014 02:50"
), class = "factor"), East = c(343565L, 343635L, 343616L, 343607L, 
343622L), North = c(6248901L, 6248937L, 6248926L, 6248913L, 6248933L
), DateTime = structure(c(9L, 15L, 10L, 2L, 14L), .Label = c("20/09/2014 00:00", 
"20/09/2014 00:10", "20/09/2014 00:20", "20/09/2014 00:30", "20/09/2014 00:40", 
"20/09/2014 00:50", "20/09/2014 01:00", "20/09/2014 01:10", "20/09/2014 01:20", 
"20/09/2014 01:30", "20/09/2014 01:40", "20/09/2014 01:50", "20/09/2014 02:00", 
"20/09/2014 02:10", "20/09/2014 02:20", "20/09/2014 02:30", "20/09/2014 02:40", 
"20/09/2014 02:50"), class = "factor"), speedFilter = structure(c(1L, 
1L, 1L, 1L, 1L), .Label = "not", class = "factor")), .Names = c("Date_Adelaide", 
"Time_Adelaide", "Site", "Lizard", "Sex", "Longitude", "Latitude", 
"Altitude", "Satellites", "HDOP", "Date_Time_Adelaide", "Date_Time_Adelaide_DHM", 
"East", "North", "DateTime", "speedFilter"), row.names = c(9L, 
15L, 10L, 2L, 14L), class = "data.frame")

我可以使用argosfilter包中的以下内容轻松计算从一个位置到下一个位置的距离:

lat<-lizard$Lat
lon<-lizard$Lon   
distanceTrack(lat, lon)

但我需要计算当天剩余时间00:00到00:10以及00:00到00:20之间的距离。我可以手动执行此操作,每次将纬度和经度复制并粘贴到不同的data.frame并运行上面的代码,但使用此方法需要很长时间。我想连续5天为20种不同的蜥蜴做,所以R中是否有一种方法或功能可以自动从一个大数据框架中执行此操作?

0 个答案:

没有答案