Skip to contents

Calculate the gradient of line segments from a 3D matrix of coordinates

Usage

slope_matrix(mat, lonlat = TRUE)

slope_weighted(mat, lonlat = TRUE, directed = FALSE)

slope_mean(mat, lonlat = TRUE, directed = FALSE)

Arguments

mat

Matrix containing coordinates and elevations. The matrix should have three columns: X, Y, and Z. In data with geographic coordinates, Z values are assumed to be in meters. In data with projected coordinates, Z values are assumed to have the same units as the X and Y coordinates.

lonlat

Are the elements provided in longitude/latitude coordinates? By default, value is from the CRS of the routes (`sf::st_is_longlat(...)`).

Value

A vector of slopes associated with each LINE element The output value is a proportion representing the change in elevation for a given change in horizontal distance.