Skip to contents

Given a set of locations defining a trajectory, this function computes the net squared displacement of the trajectory, that is the squared distances between each location and the first location of the trajectory

Usage

nsd(x, y, geo = FALSE)

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 net squared distances between each location and the first location of the trajectory.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

x <- rnorm(25)
y <- rnorm(25, sd = 3)
nsd(x, y)
#>  [1]  0.0000000 18.1102315 36.6186597 11.2771832 11.2396850  6.3807619
#>  [7]  0.8442653 14.6692764 12.4115975 10.2423384  8.7656644 11.6464895
#> [13]  2.0427850  4.4151699 15.9143821 22.9723612 53.5573732  4.5401419
#> [19] 17.0471267  3.0030174  0.2266297 27.5857797 13.8485685  8.5402427
#> [25] 10.2851483