Set lonlat to FALSE if you have projected data, e.g. with coordinates representing distance in meters, not degrees. Lonlat coodinates are assumed (lonlat = TRUE is the default).

sequential_dist(m, lonlat = TRUE)

Arguments

m

Matrix containing coordinates and elevations. The matrix should have three columns: x, y, and z, in that order. Typically these correspond to location in the West-East, South-North, and vertical elevation axes respectively. In data with geographic coordinates, Z values are assumed to be in metres. In data with projected coordinates, Z values are assumed to have the same units as the X and Y coordinates.

lonlat

Are the coordinates in lon/lat (geographic) coordinates? TRUE by default.

Value

A vector of distance values in meters if lonlat = TRUE or the map units of the input data if lonlat = FALSE between consecutive vertices.

Examples

x = c(0, 2, 3, 4, 5, 9) y = c(0, 0, 0, 0, 0, 1) m = cbind(x, y) d = sequential_dist(m, lonlat = FALSE) d
#> [1] 2.000000 1.000000 1.000000 1.000000 4.123106
nrow(m)
#> [1] 6
length(d)
#> [1] 5