Description Usage Arguments Details Value Author(s) References Examples
R wrapper for gdaldem: Tools to analyze and visualize DEMs. (since GDAL 1.7.0)
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 |
mode |
Character. ("hillshade"|"slope"|"aspect"|"color-relief"|"TRI"|"TPI"|"roughness") |
input_dem |
Character. The input DEM raster to be processed. |
output |
Character. The output raster produced. |
of |
Character. Select the output format. The default is GeoTIFF (GTiff). Use the short format name. |
compute_edges |
Logical. (GDAL >= 1.8.0) Do the computation at raster edges and near nodata values. |
alg |
Character. "ZevenbergenThorne" (GDAL >= 1.8.0) Use Zevenbergen & Thorne formula, instead of Horn's formula, to compute slope & aspect. The litterature suggests Zevenbergen & Thorne to be more suited to smooth landscapes, whereas Horn's formula to perform better on rougher terrain. |
b |
Numeric. Select an input band to be processed. Bands are numbered from 1. |
co |
Character. (GDAL >= 1.8.0) Passes a creation option ("NAME=VALUE") to the output format driver. Multiple -co options may be listed. See format specific documentation for legal creation options for each format. |
q |
Logical. Suppress progress monitor and other non-error output. |
z |
Numeric. (mode=="hillshade") vertical exaggeration used to pre-multiply the elevations. |
s |
Numeric. (mode=="hillshade" | mode=="slope) ratio of vertical units to horizontal. If the horizontal unit of the source DEM is degrees (e.g Lat/Long WGS84 projection), you can use scale=111120 if the vertical units are meters (or scale=370400 if they are in feet). |
az |
Numeric. (mode=="hillshade") azimuth of the light, in degrees. 0 if it comes from the top of the raster, 90 from the east, ... The default value, 315, should rarely be changed as it is the value generally used to generate shaded maps. |
alt |
Numeric. (mode=="hillshade") altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light. |
combined |
Character. (mode=="hillshade") "combined shading" (starting with GDAL 1.10) a combination of slope and oblique shading. |
p |
Logical. (mode=="slope") if specified, the slope will be expressed as percent slope. Otherwise, it is expressed as degrees. |
trigonometric |
Logical. (mode=="aspect") return trigonometric angle instead of azimuth. Thus 0deg means East, 90deg North, 180deg West, 270deg South. |
zero_for_flat |
Logical. (mode=="aspect") By using those 2 options, the aspect returned by gdaldem aspect should be identical to the one of GRASS r.slope.aspect. Otherwise, it's identical to the one of Matthew Perry's aspect.cpp utility. |
color_text_file |
Character. (mode=="color-relief") text-based color configuration file (see Description). |
alpha |
Logical. (mode=="color-relief") add an alpha channel to the output raster. |
exact_color_entry |
Logical. (mode=="color-relief") use strict matching when searching in the color configuration file. If none matching color entry is found, the "0,0,0,0" RGBA quadruplet will be used. |
nearest_color_entry |
Logical. (mode=="color-relief") use the RGBA quadruplet corresponding to the closest entry in the color configuration file. |
output_Raster |
Logical. Return output dst_dataset as a RasterBrick? |
ignore.full_scan |
Logical. If FALSE, perform a brute-force scan if other installs are not found. Default is TRUE. |
verbose |
Logical. Enable verbose execution? Default is FALSE. |
This is an R wrapper for the 'gdaldem' function that is part of the Geospatial Data Abstraction Library (GDAL). It follows the parameter naming conventions of the original function, with some modifications to allow for more R-like parameters. For all parameters, the user can use a single character string following, precisely, the gdalinfo format (http://www.gdal.org/gdaldem.html), or, in some cases, use R vectors to achieve the same end.
This function assumes the user has a working GDAL on their system. If the "gdalUtils_gdalPath" option has been set (usually by gdal_setInstallation), the GDAL found in that path will be used. If nothing is found, gdal_setInstallation will be executed to attempt to find a working GDAL.
The user can choose to (optionally) return a RasterBrick of the output file (assuming raster/rgdal supports the particular output format).
NULL or if(output_Raster), a RasterBrick.
Jonathan A. Greenberg (gdalUtils@estarcion.net) (wrapper) and Matthew Perry, Even Rouault, Howard Butler, and Chris Yesson (GDAL developers).
http://www.gdal.org/gdaldem.html
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 32 33 34 35 36 37 38 | # We'll pre-check to make sure there is a valid GDAL install
# and that raster and rgdal are also installed.
# Note this isn't strictly neccessary, as executing the function will
# force a search for a valid GDAL install.
outdir <- tempdir()
gdal_setInstallation()
valid_install <- !is.null(getOption("gdalUtils_gdalPath"))
if(require(raster) && require(rgdal) && valid_install)
{
# We'll pre-check for a proper GDAL installation before running these examples:
gdal_setInstallation()
if(!is.null(getOption("gdalUtils_gdalPath")))
{
input_dem <- system.file("external/tahoe_lidar_highesthit.tif", package="gdalUtils")
plot(raster(input_dem),col=gray.colors(256))
# Hillshading:
# Command-line gdaldem call:
# gdaldem hillshade tahoe_lidar_highesthit.tif output_hillshade.tif
output_hillshade <- gdaldem(mode="hillshade",input_dem=input_dem,
output=file.path(outdir,"output_hillshade.tif"),output_Raster=TRUE,verbose=TRUE)
plot(output_hillshade,col=gray.colors(256))
# Slope:
# Command-line gdaldem call:
# gdaldem slope tahoe_lidar_highesthit.tif output_slope.tif -p
output_slope <- gdaldem(mode="slope",input_dem=input_dem,
output=file.path(outdir,"output_slope.tif"),p=TRUE,output_Raster=TRUE,verbose=TRUE)
plot(output_slope,col=gray.colors(256))
# Aspect:
# Command-line gdaldem call:
# gdaldem aspect tahoe_lidar_highesthit.tif output_aspect.tif
output_aspect <- gdaldem(mode="aspect",input_dem=input_dem,
output=file.path(outdir,"output_aspect.tif"),output_Raster=TRUE,verbose=TRUE)
plot(output_aspect,col=gray.colors(256))
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.