Calculate the gradient of line segments from a matrix of coordinates
Calculate the gradient of line segments from a matrix of coordinates
route_slope_matrix(m, e = m[, 3], lonlat = TRUE)
m |
Matrix containing coordinates and elevations |
e |
Elevations in same units as x (assumed to be metres) |
lonlat |
Are the coordinates in lon/lat order? |
Other route_funs:
route_average_gradient()
,
route_rolling_average()
,
route_rolling_diff()
,
route_rolling_gradient()
,
route_sequential_dist()
,
route_slope_vector()
x <- c(0, 2, 3, 4, 5, 9) y <- c(0, 0, 0, 0, 0, 9) z <- c(1, 2, 2, 4, 3, 1) / 10 m <- cbind(x, y, z) plot(x, z, ylim = c(-0.5, 0.5), type = "l") (gx <- route_slope_vector(x, z)) (gxy <- route_slope_matrix(m, lonlat = FALSE)) abline(h = 0, lty = 2) points(x[-length(x)], gx, col = "red") points(x[-length(x)], gxy, col = "blue") title("Distance (in x coordinates) elevation profile", sub = "Points show calculated gradients of subsequent lines" )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.