#' Function for computing slope in degrees
#'
#' This is a convenient (maybe?) wrapper around \code{raster::terrain()}.
#'
#' @usage hf_slope(dem)
#'
#' @param dem A \code{RasterLayer} with elevation values in the same units as crs.
#'
#' @return A \code{RasterLayer} with slope values in degrees.
#' @export
#'
#' @examples
#' \dontrun{
#'
#' library(raster)
#'
#' dem <- raster(system.file("extdata/slc.grd", package = "rHike"))
#'
#' slope <- hf_slope(dem)
#'
#' plot(slope)
#'
#' }
#'
hf_slope <- function(dem){
raster::terrain(x = dem,
opt = "slope",
unit = "degrees",
neighbors = 8)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.