I am using the package AdehabitatLT to interpolate tracking data.
I am working of GPS tracks from diving seabirds, devices were set to
record locations every 60s but due to the diving behaviour of the birds I
have a lot of missing location data. In order to carry out further
analyses I need a regular trajectory so I am trying to interpolate the
tracks to every 60s. I have been using the package AdehabitatLT and have
created an ltraj object for the tracks, and managed to interpolate the
data, however when the data is interpolated I lose the data stored within
the infolocs component. I'm guessing it is something to do with the
lengths of the dataframes differing. Is there any way to transfer the
infolocs data to the interpolated values replacing any missing rows/values
with NAs?
R code:
# Creation of a "ltraj" object, with metadata ("infolocs")
tr1 <- as.ltraj(xy,date = da,id=id,infolocs = birdData[,6:15])
List of 1
$ :'data.frame': 4188 obs. of 10 variables:
..$ x : num [1:4188] -1.66 -1.66 -1.66 -1.65 -1.66 ...
..$ y : num [1:4188] 55.6 55.6 55.6 55.6 55.6 ...
..$ date : POSIXct[1:4188], format: "2014-05-06 10:17:46"
"2014-05-06 10:20:34" "2014-05-06 10:21:27" "2014-05-06 10:22:20" ...
..$ dx : num [1:4188] -0.000206 -0.000587 0.003507 -0.002726
0.0001 ...
..$ dy : num [1:4188] -0.000828 0.00349 -0.002739 -0.000011
-0.000042 ...
..$ dist : num [1:4188] 0.000853 0.003539 0.00445 0.002726 0.000108
...
..$ dt : num [1:4188] 168 53 53 57 57 53 53 54 56 53 ...
..$ R2n : num [1:4188] 0.00 7.28e-07 7.72e-06 7.37e-06 7.89e-09
...
..$ abs.angle: num [1:4188] -1.815 1.737 -0.663 -3.138 -0.398 ...
..$ rel.angle: num [1:4188] NA -2.73 -2.4 -2.47 2.74 ...
..- attr(*, "id")= chr "1465801"
..- attr(*, "burst")= chr "1465801"
..- attr(*, "infolocs")='data.frame': 4188 obs. of 10
variables:
.. ..$ GPS_ALT : num [1:4188] 18.61 2.82 7.12 21.22 24.39 ...
.. ..$ GPS_SPD : int [1:4188] 5184 29088 48780 33732 1008 504 756 396
0 0 ...
.. ..$ GPS_CRS : int [1:4188] 181 88 238 130 179 109 12 137 22 164 ...
.. ..$ LOC_TYPE : int [1:4188] 0 0 0 0 0 0 0 0 0 0 ...
.. ..$ GPS_DIST : num [1:4188] 0 93 390 376 171 ...
.. ..$ Essential: int [1:4188] NA NA NA NA NA NA NA NA NA NA ...
.. ..$ time_numb: num [1:4188] 0.429 0.431 0.432 0.432 0.433 ...
.. ..$ BIRDID : int [1:4188] 1465801 1465801 1465801 1465801 1465801
1465801 1465801 1465801 1465801 1465801 ...
.. ..$ SEX : Factor w/ 1 level "M": 1 1 1 1 1 1 1 1 1 1 ...
.. ..$ SUBCOL : Factor w/ 1 level "IF": 1 1 1 1 1 1 1 1 1 1 ...
- attr(*, "class")= chr [1:2] "ltraj" "list"
- attr(*, "typeII")= logi TRUE
- attr(*, "regular")= logi FALSE
#interpolation of one track, at 60s.
tr1.interp<- redisltraj(na.omit(tr1), 60, type = "time")
str(tr1.interp)
List of 1
$ :'data.frame': 132864 obs. of 10 variables:
..$ x : num [1:132864] -1.66 -1.66 -1.66 -1.66 -1.65 ...
..$ y : num [1:132864] 55.6 55.6 55.6 55.6 55.6 ...
..$ date : POSIXct[1:132864], format: "2014-05-06 10:17:46"
"2014-05-06 10:18:46" "2014-05-06 10:19:46" "2014-05-06 10:20:46" ...
..$ dx : num [1:132864] -7.36e-05 -7.36e-05 -1.92e-04 8.03e-04
1.01e-03 ...
..$ dy : num [1:132864] -0.000296 -0.000296 0.000554 0.001718
-0.001762 ...
..$ dist : num [1:132864] 0.000305 0.000305 0.000586 0.001896
0.002029 ...
..$ dt : num [1:132864] 60 60 60 60 60 60 60 60 60 60 ...
..$ R2n : num [1:132864] 0.00 9.29e-08 3.71e-07 1.16e-07 3.04e-06
...
..$ abs.angle: num [1:132864] -1.81 -1.81 1.9 1.13 -1.05 ...
..$ rel.angle: num [1:132864] NA 0 -2.564 -0.771 -2.185 ...
..- attr(*, "id")= chr "1465801"
..- attr(*, "burst")= chr "1465801"
..- attr(*, "infolocs")='data.frame': 132864 obs. of 1
variable:
.. ..$ pkey: Factor w/ 132864 levels "1465801.2014-05-06 10:17:46",..:
1 2 3 4 5 6 7 8 9 10 ...
- attr(*, "class")= chr [1:2] "ltraj" "list"
- attr(*, "typeII")= logi TRUE
- attr(*, "regular")= logi TRUE
Any help would be much appreciated
Thanks,
Liz