The function takes a sf object with 'XYZ' coordinates and returns a vector of numeric values representing the average slope of each linestring in the sf data frame input.
Arguments
- route_xyz
An
sf
orsfc
object withXYZ
coordinate dimensions- fun
The slope function to calculate per route,
slope_matrix_weighted
by default.- lonlat
Are the coordinates in lon/lat order? TRUE by default
- directed
Should the value be directed?
FALSE
by default. IfTRUE
the result will be negative when it represents a downslope (when the end point is lower than the start point).
Value
A vector of slopes equal in length to the number simple features (rows representing linestrings) in the input object.
Details
The default function to calculate the mean slope is slope_matrix_weighted()
.
You can also use slope_matrix_mean()
from the package or any other
function that takes the same inputs as these functions not in the package.
Examples
route_xyz = lisbon_road_segment_3d
slope_xyz(route_xyz, lonlat = FALSE)
#> 1
#> 0.09501323
slope_xyz(route_xyz$geom, lonlat = FALSE)
#> 1
#> 0.09501323
slope_xyz(route_xyz, lonlat = FALSE, directed = TRUE)
#> 1
#> -0.09501323
slope_xyz(route_xyz, lonlat = FALSE, fun = slope_matrix_mean)
#> 1
#> 0.09283052