Skip to contents

These functions thin trajectories, by selecting segments from the original track with a fixed time interval or distance. Finding all segments of a specific time interval might for example be useful for fitting step selection functions.

Usage

thinTrackTime(x, interval = NA, tolerance = NA,
  criteria = c("closest", "first", "all"), ...)
thinDistanceAlongTrack(x, interval = NA, tolerance = NA,
  criteria = c("closest", "first", "all"), ...)

Arguments

x

a move object

interval

in thinTrackTime a object of class difftime specifying a time interval. See 'Examples'.
in thinDistanceAlongTrack a numeric value specifying a distance. The units will correspond to the map units. If the coordinates are in long/lat, than the value should be provided in meters.

tolerance

in thinTrackTime a object of class difftime specifying the tolerance of the specified interval. See 'Examples'.
in thinDistanceAlongTrack a numeric value specifying the tolerance of the specified interval

criteria

the criteria ("closest", "first" or "all") to be used when multiple solutions are available. Default is "closest".

...

Currently not implemented.

Details

The functions search for consecutive segments with a cumulative sum of the time lag (or distance) corresponding to interval and tolerance values. From each selected chunk of the track, only the first and last location are kept in the new object, this new segment is labeled with "selected". The segments labeled as "notSelected" are those parts of the track that did not fulfill the indicated interval. A "notSelected" burst can correspond to multiple consecutive segments that have a larger timelag than the one specified, or a single large time gap that is present in the original data.
Note that in the case of thinDistanceAlongTrack, the distances between the locations in the new object do not represent the distance that the animal actually traveled, as the intermediate location are removed.

Note

This function finds the maximal number of segments that meet the criteria but does not ensure that the average matches the set interval.

Value

A MoveBurst object, with segments labeled either 'selected' or 'notSelected', only the selected segments match the criteria set in the function call.

A list of MoveBurst objects will all possible solutions if the criteria is set to "all".

Author

Bart Kranstauber & Anne Scharf

See also

Examples

data("leroy")
leroysub <- leroy[1:200]
### selecting those segments that have a time interval of 15mins pulsminus 5mins
thintime <- thinTrackTime(leroysub, interval = as.difftime(15, units='mins'),
                          tolerance = as.difftime(5, units='mins'))
summary(timeLag(thintime,"mins")[thintime@burstId=="selected"])
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   13.77   14.72   14.98   14.99   15.27   16.52 

### selecting those segments that have a distance of 100m pulsminus 10m
thindist <- thinDistanceAlongTrack(leroysub, interval = 100, tolerance = 10)
summary(distance(thindist)[thindist@burstId=="selected"])
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   2.085  21.245  30.156  42.116  74.166  96.185 

# \dontshow{
timeLag(thinTrackTime(move(1:40, 1:40, Sys.time()+1:40), 
as.difftime(5, units='secs'), as.difftime(1, units='secs')), units='secs')
#> [1] 4 4 4 4 4 4 5 5 5

timeLag(thinTrackTime(move(1:41, 1:41, Sys.time()+1:41), 
as.difftime(5, units='secs'), as.difftime(1, units='secs')), units='secs')
#>  [1] 4 4 4 4 4 4 4 4 4 4
# }