Given a set of locations defining a trajectory, this function computes the linear speeds between each pair of successive locations along the trajectory.
Arguments
- x
A vector of x (or longitude) coordinates corresponding to a single trajectory.
- y
A vector of y (or latitude) coordinates corresponding to a single trajectory.
- t
A vector of timestamps corresponding to a single trajectory.
- geo
A logical value indicating whether the locations are defined by geographic coordinates (pairs of longitude/latitude values). Default: FALSE.
Value
A vector of the same length as x and y corresponding to the linear speeds between each pair of successive locations along the trajectory.
Author
Simon Garnier, garnier@njit.edu
Examples
x <- rnorm(25)
y <- rnorm(25, sd = 3)
t <- as.POSIXct(1:25, origin = Sys.time())
linear_speed(x, y, t)
#> [1] NA 4.6482227 1.6677522 1.0535864 4.8443862 3.0080051
#> [7] 4.5872454 2.0179815 0.8756391 4.1277026 6.5890259 1.5581156
#> [13] 4.3660668 3.0691020 2.3229016 3.5775332 8.3640095 6.5134270
#> [19] 5.6713968 2.9208618 4.5924518 3.5660889 2.0515297 7.3394745
#> [25] 14.3260631