FilterTraj | R Documentation |
The function FilterTraj
is a function for extracting portions of a trajectory based on some filter criteria.
FilterTraj(traj, type = "attribute", filter = NA)
traj |
an object of the class |
type |
The type of filter to apply (one of 'attribute',temporal','tod'). |
filter |
The filter criteria (see details). |
The function FilterTraj
can be used to extract a portion of a trajectory based on temporal criteria (such as time-of-day or a temporal window) or based on attributes of the trajectory. In the case of attribute filtering, the criteria can be any of the default attributes of an ltraj
object, or based on additional attributes stored alongside the trajectory. The filter
parameter is a flexible way to define the criteria for filtering. The filter
object can be one of:
- POSIX
class objects (list of length=2) for filtering based on some temporal window (see examples);
- character
object (list of length=2) for filtering based on time-of-day (see examples);
- character
object containing the attribute filter criteria as a logical expression (see examples and ?subset
).
NOTE: When using FilterTraj
be very careful about using the output ltraj
object in further analysis. When a new ltraj
object is created, all the movement parameters (e.g., dist, dt) are recalculated and thus not necessarily valid. Therefore, subsequent analysis should ideally focus only on the raw fix information (i.e., x, y, date).
A ltraj
object with only those fixes satisfying the filter
criteria.
GetTO
data(deer)
deer37 <- deer[1]
deer38 <- deer[2]
#Temporal Filter
t1 <- as.POSIXct(strptime('2005-03-09 00:00:00', format= '%Y-%m-%d %H:%M:%S'))
t2 <- as.POSIXct(strptime('2005-03-11 00:00:00', format= '%Y-%m-%d %H:%M:%S'))
twin <- c(t1,t2)
x <- FilterTraj(deer37,type='temporal',filter=twin)
#tod Filter
tod <- c('06:00:00', '10:00:00')
x <- FilterTraj(deer37,type='tod',filter=tod)
#attribute Filter
q <- 'dist > 100'
x <- FilterTraj(deer37,type='attribute',filter=q)
q <- 'dist > 100 & rel.angle < 1'
x <- FilterTraj(deer37,type='attribute',filter=q)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.