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.
slope_xyz( route_xyz, fun = slope_matrix_weighted, lonlat = TRUE, directed = FALSE )
route_xyz | An |
---|---|
fun | The slope function to calculate per route,
|
lonlat | Are the coordinates in lon/lat order? TRUE by default |
directed | Should the value be directed? |
A vector of slopes equal in length to the number simple features (rows representing linestrings) in the input object.
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.
route_xyz = lisbon_road_segment_3d slope_xyz(route_xyz, lonlat = FALSE)#> 1 #> 0.09501323slope_xyz(route_xyz$geom, lonlat = FALSE)#> 1 #> 0.09501323slope_xyz(route_xyz, lonlat = FALSE, directed = TRUE)#> 1 #> -0.09501323slope_xyz(route_xyz, lonlat = FALSE, fun = slope_matrix_mean)#> 1 #> 0.09283052