gdaldem: Interface to GDAL's gdaldem utility

Description Usage Arguments Value Author(s) Examples

View source: R/gdaldem.R

Description

This function provides an interface mirroring that of the GDAL command-line app gdaldem. For a description of the utility and the arguments that it takes, see the documentation at https://gdal.org/programs/gdaldem.html.

Usage

 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
gdaldem(
  mode,
  input_dem,
  output_map,
  ...,
  of,
  compute_edges,
  alg,
  b,
  co,
  q,
  z,
  s,
  az,
  alt,
  combined,
  multidirectional,
  igor,
  p,
  trigonometric,
  zero_for_flat,
  color_text_file = character(0),
  alpha,
  exact_color_entry,
  nearest_color_entry,
  dryrun = FALSE
)

Arguments

mode

Character, one of "hillshade", "slope", "color-relief", "TRI", "TPI", "roughness", indicating which of the available processing modes is to be used.

input_dem

Path to a GDAL-supported readable DEM datasource.

output_map

Character. Path to a GDAL-supported output file.

...

Here, a placeholder argument that forces users to supply exact names of all subsequent formal arguments.

of, compute_edges, alg, b, co, q, z, s, az, alt, combined

See the GDAL project's gdaldem documentation for details.

multidirectional, igor, p, trigonometric, zero_for_flat

See the GDAL project's gdaldem documentation for details.

color_text_file, alpha, exact_color_entry, nearest_color_entry

See the GDAL project's gdaldem documentation for details.

dryrun

Logical (default FALSE). If TRUE, instead of executing the requested call to GDAL, the function will print the command-line call that would produce the equivalent output.

Value

None. Called instead for its side effect.

Author(s)

Joshua O'Brien

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
## Prepare file paths
td <- tempdir()
in_dem <- system.file("extdata/maunga.tif", package = "gdalUtilities")
out_slope  <- file.path(td, "slope.tif")
out_shade  <- file.path(td, "shade.tif")
out_aspect <- file.path(td, "aspect.tif")

## Apply DEM processing
gdaldem("slope", in_dem, out_slope)
gdaldem("shade", in_dem, out_shade)
gdaldem("aspect", in_dem, out_aspect)

## View results
if(requireNamespace("raster", quietly = TRUE)) {
  library(raster)
  if(require(rasterVis)) {
    lp <- function(f) {
        levelplot(raster(f), main = substitute(f),
                  margin = FALSE, colorkey = FALSE)
    }
    plot(lp(in_dem),     split = c(1,1,2,2))
    plot(lp(out_slope),  split = c(2,1,2,2), newpage = FALSE)
    plot(lp(out_shade),  split = c(1,2,2,2), newpage = FALSE)
    plot(lp(out_aspect), split = c(2,2,2,2), newpage = FALSE)
  }
}

gdalUtilities documentation built on Oct. 26, 2021, 5:06 p.m.