Given a set of locations defining a trajectory, this function approximates their instantaneous headings computed as the direction of the vectors between 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.
- 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 approximated headings along the trajectory.
Author
Simon Garnier, garnier@njit.edu
Examples
x <- rnorm(25)
y <- rnorm(25, sd = 3)
heading(x, y)
#> [1] NA -1.25929093 2.28416873 1.66769775 -2.02116749 0.78349635
#> [7] 2.54168267 0.07308071 -1.29115309 -1.65437433 1.62121152 -1.56887406
#> [13] 0.71555923 -2.41995361 1.64635191 1.10715877 -1.63370975 -0.37132905
#> [19] 0.65822319 2.83369532 1.01450472 1.74093488 -1.97611127 -1.51830078
#> [25] 1.67101453