rdata-sciencemovergdalgeosphere

Interpolating data using the package move: How to create a movestack object?


I have just started using R for my masters thesis project, and i am trying to interpolate the sampling rate for my penguin tracking data using the package move. However when trying to create a movestack object i get this error:

Error in validityMethod(as(object, superClass)) : 
  There are NA timestamps records

and this warning message

In addition: Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum WGS_1984 in Proj4 definition

the code:

alltripsfiltered <- read.csv(file = "C:/Users/Admin/OneDrive - Massey University/Documents/Korora/GPS data for all trips/alltracksfiltered00.csv")

tracks.move<- move(x=alltripsfiltered$Long, y=alltripsfiltered$Lat, time =as.POSIXct(alltripsfiltered$datetime, format="%Y-%m-%d %H:%M:%OS", tz="UTC"), proj=CRS("+init=epsg:3857"), animal=alltripsfiltered$TripID)

and the data:

dput(alltripsfiltered[1:6, ])
structure(list(X = 1:6, Deployment = c(1L, 1L, 1L, 1L, 1L, 1L
), Device = c(2L, 2L, 2L, 2L, 2L, 2L), Box.no. = c("C23", "C23", 
"C23", "C23", "C23", "C23"), Bird.no. = c(10825325L, 10825325L, 
10825325L, 10825325L, 10825325L, 10825325L), Breeding.Stage = c(1L, 
1L, 1L, 1L, 1L, 1L), Long = c(174.78327, 174.78326, 174.78332, 
174.78323, 174.78325, 174.78277), Lat = c(-41.09482, -41.09491, 
-41.09484, -41.09491, -41.09496, -41.09564), datetime = c("18/09/2020 4:13", 
"18/09/2020 4:14", "18/09/2020 4:15", "18/09/2020 4:16", "18/09/2020 4:17", 
"18/09/2020 4:18"), TripID = c(1L, 1L, 1L, 1L, 1L, 1L), Trip.no. = c(1L, 
1L, 1L, 1L, 1L, 1L), Complete = c(0L, 0L, 0L, 0L, 0L, 0L), optional = c(TRUE, 
TRUE, TRUE, TRUE, TRUE, TRUE)), row.names = c(NA, 6L), class = "data.frame")

I am unsure if this is happening because of an issue in R or with my dataset. I intend on running the remainder of the code using the ‘movestack’ object to then split into separate trips so i can extract the values to use for calculating home range:

tracks.split<- split(tracks.move)
##interpolate the first track
track1interpolated<-interpolateTime(tracks.split$X1, time=as.difftime(1, units="mins"), spaceMethod=c('greatcircle'))
track1interpolated
##continue to do this for all tracks (change to X2, X3….), 

Solution

  • Your datetime input is not as the same format as you put in the time argument :

    tracks.move<- move(x=alltripsfiltered$Long, y=alltripsfiltered$Lat, time =as.POSIXct(alltripsfiltered$datetime, format="%d/%m/%Y %H:%M", tz="UTC"), 
                       proj=CRS("+init=epsg:3857"), animal=alltripsfiltered$TripID)