R/hf_slope.R

Defines functions hf_slope

Documented in hf_slope

#' 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)

}
kbvernon/rHike documentation built on May 29, 2020, 7:22 p.m.