Skip to content
Prev 3823 / 7420 Next

Topic: creating an object of class ltraj.

Hi Dylann,
It would be great if you could provide us the output of these commands. 
For example, to type:

head(date)

Just a guess: according to your description, it works. Y/M/D is the way 
the dates are displayed (try to type Sys.time() at the command prompt: 
it gives the current date and time in POSIX format)
You don't have to. Objects of class ltraj are not Spatial* objects. Look 
at the help page of as.ltraj:

      as.ltraj(xy, date, id, burst = id, typeII = TRUE,
               slsp = c("remove", "missing"),
               infolocs = data.frame(pkey = paste(id, date, sep=".")))

with xy: a data.frame containing the x and y coordinates of the
           relocations
if you type coordinates(data) <- c("X","Y"), xy is no longer a 
dataframe, but a SpatialPointsDataFrame (check it with class(data)).
So avoid this command before defining your ltraj object. Then, the 
following commands should work:

date <- as.POSIXct(strptime(paste(data$Date, data$Time), "%d/%m/%Y
%H:%M:%S"), "GMT")
data_timestamp <- data.frame(data, timestamp=date)
traj <- as.ltraj(data_timestamp[,c("X","Y")],  date=date, id=data_timestamp$name, typeII=TRUE)


HTH,

Cl?ment Calenge