Description Usage Arguments Details Value See Also Examples
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.
1 |
cgrad |
A 3D array of dimensions [ |
degrees |
Logical. If |
Uses atan2()
to compute the orientation within the range [0, 2π]
Aspect or orientation of the slope.
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 | # 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)
## Not run: ## raster package display nicer than image and handles projections:
# Calculate the aspect of a rough mountain area in the pyrinees
zipfile = tempfile()
download.file("https://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))
require(raster)
demfile = tempfile()
download.file("https://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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.