I need to calculate the distance between different GPS locations to look at lizard movement and I am wanting to see when they start and stop moving. So I need to calculate the distance from one location to all other locations.
This is the dput output of the first 3 hours of one day for one lizard:
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")
I can easily calculate the distance from one location to the next using the following from the argosfilter package:
lat<-lizard$Lat
lon<-lizard$Lon
distanceTrack(lat, lon)
But I am needing to calculate the distance from the location at 00:00 to 00:10 and then between 00:00 to 00:20 etc. for the rest of the day. I can do this manually by copying and pasting the latitude and longitude each time into a different data.frame and running the above code but it takes a long time to get anywhere with this method. I am wanting to do 5 consecutive days for 20 different lizards so is there a method or function in R to do this automatically from one big data.frame?