Learn R Programming

trip (version 1.1-1)

trackDistance: Determine distance along a track

Description

Calculate the distance between subsequent 2-D coordinates using Euclidean or Great Circle distance (WGS84 ellipsoid) methods.

Usage

trackDistance(x1, y1, x2, y2, longlat = TRUE)

Arguments

x1
matrix of 2-columns, with x/y coordinates OR a vector of x start coordinates
x2
vector of x end coordinates, if x1 is not a matrix
y1
vector of y start coordinates, if x1 is not a matrix
y2
vector of y end coordinates, if x1 is not a matrix
longlat
if FALSE, Euclidean distance, if TRUE Great Circle distance

Value

  • Vector of distances between coordinates.

Details

trackDistance calls source code identical to sp's spDistN when longlat is TRUE. This originally used spDistsN1 but now implements the sp gcdist source directly in R.

References

Original source taken from sp package.