# aspect: Aspect or orientation of the slope In insol: Solar Radiation

## Description

Calculates the aspect of every grid cell in a digital elevation model (DEM) from the output of cellgradient, which is a set of unit vectors normal to every grid cell in the DEM.

## Usage

 `1` ```aspect(cgrad, degrees = FALSE) ```

## Arguments

 `cgrad` A 3D array of dimensions [`nrow(dem)`, `ncol(dem)`, 3], where the third dimensions are the x, y, z component of the unit vectors normal to the surface of the DEM grid cells. `degrees` Logical. If `FALSE`, returns radians, if `TRUE`, returns degreees.

## Details

Uses `atan2()` to compute the orientation within the range [0, 2π]

## Value

Aspect or orientation of the slope.

`slope`, `cgrad`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31``` ```# Create a west-east facing ramp slpwe=rep(1,10) %o% c(1:5,4:1) # calculate the aspect at every node or grid cell (it should be 270 or 90 degrees): cgr=cgrad(slpwe,1) aspect(cgr,degrees=TRUE) # Calculate the aspect of a rough mountain area in the pyrinees zipfile=tempfile() download.file("http://www.meteoexploration.com/R/insol/data/dempyrenees.asc.zip",zipfile) header=read.table(unz(zipfile,'dempyrenees.asc'),nrows=6) dem = read.table(unz(zipfile,'dempyrenees.asc'),skip=6) dem=as.matrix(dem) unlink(zipfile) cellsize=header[5,2] aspectdem=aspect(cgrad(dem,cellsize),degrees=TRUE) image(t(aspectdem[nrow(aspectdem):1,]),col=grey(1:100/100)) ## Not run: ## raster package display nicer than image and handles projections: require(rgdal) require(raster) demfile=tempfile() download.file("http://www.meteoexploration.com/R/insol/data/dempyrenees.tif",demfile) dem=raster(demfile) aspectdem=aspect(cgrad(dem),degrees=TRUE) aspectdem=raster(aspectdem,crs=projection(dem)) extent(aspectdem)=extent(dem) plot(aspectdem,col=grey(1:100/100)) unlink(demfile) ## End(Not run) ```

insol documentation built on May 29, 2017, 3:22 p.m.