Learn R Programming

slopes (version 1.0.1)

sequential_dist: Calculate the sequential distances between sequential coordinate pairs

Description

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).

Usage

sequential_dist(m, lonlat = TRUE)

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.

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.

Examples

Run this code
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
nrow(m)
length(d)

Run the code above in your browser using DataLab