Last chance! 50% off unlimited learning
Sale ends in
Calculate the gradient of line segments from a matrix of coordinates
route_slope_matrix(m, e = m[, 3], lonlat = TRUE)
Matrix containing coordinates and elevations
Elevations in same units as x (assumed to be metres)
Are the coordinates in lon/lat order? TRUE
by default
Other route_funs:
route_average_gradient()
,
route_rolling_average()
,
route_rolling_diff()
,
route_rolling_gradient()
,
route_sequential_dist()
,
route_slope_vector()
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab