Dear Tim,

[snip]
As I understand it, the tol level determines how close the date value should be to dt.  
However, in my example I have a time of 13:49 which is 4 minutes from 13:45.  This should 
return NA in my thinking, not be rounded down to 13:45.  Also, the first value returned 
should have been the 13:29 data since it is closer to 13:30 than the 13:31:30 data.  I 
would appreciate your help in explaining "tol" and how to set limits for my 
data.  Please cc mudiver1...@yahoo in your reply.  Otherwise my browser won't let me 
respond to the thread.

Not exactly. Actually, sett0 is not intended to transform an irregular trajectory into a regular one, it is provided to "round" the timing of relocations of theoretically regular trajectories, so that the resulting trajectory is exactly regular. The help page indicates:

"many functions of 'adehabitat' require exact regular trajectories. 'sett0' allows to round the date so that all the successive relocations are separated exactly by 'dt'. *****The function 'sett0' requires that the imprecision is at most equal to 'tol'****. "

Therefore, it is required that the imprecision is at most equal to tol in the trajectory. Similarly for setNA, the help page indicates:

"This function places missing values in ****an (approximately) regular trajectory***, when a relocation should have been collected, but is actually missing."

Now, consider your case:

 da<-as.POSIXct(c("2009-07-31 13:29:00", "2009-07-31 13:31:30", "2009-07-31 13:49:00", "2009-07-31 
14:00:00","2009-07-31 14:15:00", "2009-07-31 14:45:00"))


The trajectory is not regular with a tolerance of 2 minutes (the first two relocations are separated by a lag of 2 min 30 instead of 15) and does not respect this constraint. The result is therefore:

>   t3<-sett0(t2, refda, dt=15,tol=2, units = "min")
Error in FUN(1L[[1L]], ...) :
 ltraj contains irregular data (time lag > or < tol)

This indicates that some data management is required before the use of this function... for example the following code is ok:

#Trajectory variables
x<-c(808993.9,809172.2,809271.6,809284.6 ,809552.3,809364.3)
y<-c(2189323,2189721,2190037,2190296,2190984,2191737)
xy<-data.frame(x,y)
names(xy)<-c("Long.utm","Lat.utm")
id<-as.character(rep("Test",6))
da<-as.POSIXct(c("2009-07-31 13:29:00", "2009-07-31 13:31:30", "2009-07-31 13:49:00", "2009-07-31 
14:00:00","2009-07-31 14:15:00", "2009-07-31 14:45:00"))

## remove the first one:
da <- da[-1]
xy<-xy[-1,]
id <- id[-1]

#Create type II trajectory
t1<- as.ltraj(xy,id=id,date=da)## use sett0

## use setNA with a tolerance of 5 minutes (2 min will fail: ## according to this tolerance, the data are irregular [the ## second relocation is more than 2 min from when it should be ## - 4 min actually])
refda <- strptime("00:00", "%H:%M")
t2 <- setNA(t1, refda, dt=15, tol = 5, units = "min")

## use sett0 with a tolerance of 5 minutes for the same reason
t3<-sett0(t2, refda, dt=15,tol=4, units = "min")


And the result is:

> t3

*********** List of class ltraj ***********

Type of the traject: Type II (time recorded)
Regular traject. Time lag between two locs: 900 seconds

Characteristics of the bursts:
   id burst nb.reloc NAs          date.begin            date.end
1 Test  Test        6   1 2009-07-31 13:30:00 2009-07-31 14:45:00

The trajectory is regular and contains one missing value.
Hope this helps,


Clément Calenge

--
Clément CALENGE
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14

_______________________________________________
AniMov mailing list
[email protected]
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov

Reply via email to