Compute a Slope Raster from a DEM
get_slope.RdComputes a slope raster (in degrees) either by:
downloading a DEM automatically using
x, orusing a DEM raster supplied manually through the
demargument.
Arguments
- x
sforsfc; Geometry located in France.- dem
SpatRasterrepresenting ground elevation (DEM). Must be supplied only whenxisNULL.- agg
numeric; Target resolution (in meters) to which the DEM is aggregated if its native resolution is finer. Default:5.- verbose
logical; IfTRUE, display messages.- ...
Additional parameters passed to
get_dem()whenxis supplied.
Details
When x is provided, the DEM is obtained with get_dem(), using by
default a resolution equal to agg.
When x is not provided, a DEM must be supplied via dem.
If the DEM resolution is finer than agg, the raster is aggregated to
avoid artefacts and reduce computation time.
Slope is computed with terra::terrain() using Horn's 8-neighbor algorithm,
and returned in degrees.
Aggregation is performed with terra::aggregate() using a mean function.
This is recommended when high-resolution DEMs (<5 m) would otherwise
generate line artefacts.
Examples
if (FALSE) { # \dontrun{
# Automatic download mode
s <- get_slope(x = my_polygon, buffer = 200)
# Manual mode
dem <- get_dem(my_polygon)
s <- get_slope(dem = dem)
} # }