Learn R Programming

SDMTools (version 1.1-221)

slope: Slope and aspect calculations

Description

slope and aspect calculates the slope and aspect of raster surfaces of class 'asc' (SDMTools & adehabitat packages), 'RasterLayer' (raster package) or 'SpatialGridDataFrame' (sp package). Methods are based on Burrough and McDonell (1998).

Usage

slope(mat, latlon = FALSE)
aspect(mat, latlon = FALSE)

Arguments

mat
a matrix of data representing z heights. Matrix can be a raster of class 'asc' (adehabitat package), 'RasterLayer' (raster package) or 'SpatialGridDataFrame' (sp package)
latlon
boolean value representing if the data is geographic.

Value

an object of the same class as mat.

Details

Slope returns values representing the 'rise over run' with "run" units representing cellsize if latlon=FALSE or km if latlon=TRUE. This can be changed to percentage (multiply by 100) or to degrees by ATAN ( output ) * 57.29578. Aspect returns the direction (0 to 360) with North being 0. Values of -1 are flat areas with no slope or aspect. As this method requires information from the surrounding cells, missing data (NAs or edges) are populated with the value from the 'cell-of-interest').

References

Burrough, P. A. and McDonell, R.A., 1998. Principles of Geographical Information Systems (Oxford University Press, New York), p. 190.

Examples

Run this code
#define a simple asc with some slope and direction
tasc = as.asc(matrix(1:50,nr=10,nc=5),yll=75); tasc[,]
slope(tasc)[,] #show the output of slope
aspect(tasc)[,] #show the output of the aspect

#define a FLAT simple asc
tasc = as.asc(matrix(10,nr=10,nc=5),yll=75); tasc[,]
slope(tasc)[,] #show the output of slope
aspect(tasc)[,] #show the output of the aspect

Run the code above in your browser using DataLab