rsaga.esri.wrapper: Use RSAGA functions for ESRI grids

View source: R/RSAGA-core.R

rsaga.esri.wrapperR Documentation

Use RSAGA functions for ESRI grids

Description

This wrapper converts input grid files provided in ESRI binary (.flt) or ASCII (.asc) formats to SAGA's (version 2) grid format, calls the RSAGA geoprocessing function, and converts the output grids back to the ESRI grid format. Conversion can also be limited to either input or output grids.

Usage

rsaga.esri.wrapper(
  fun,
  in.esri = TRUE,
  out.esri = TRUE,
  env = rsaga.env(),
  esri.workspace = env$workspace,
  format = "ascii",
  georef = "corner",
  prec = 5,
  esri.extension,
  condensed.res = TRUE,
  clean.up = TRUE,
  intern = TRUE,
  ...
)

Arguments

fun

function: one of the RSAGA geoprocessing functions, such as rsaga.close.gaps() or rsaga.hillshade() etc.

in.esri

logical: are input grids provided as ESRI grids (in.esri=TRUE) or as SAGA grids?

out.esri

logical: should output grids be converted to ESRI grids?

env

RSAGA environment as returned by rsaga.env()

esri.workspace

directory for the input and output ESRI ASCII/binary grids

format

output file format, either "ascii" (default; equivalent: format=1) for ASCII grids or "binary" (equivalent: 0) for binary ESRI grids (.flt).

georef

character: "corner" (equivalent numeric code: 0) or "center" (default; equivalent: 1). Determines whether the georeference will be related to the center or corner of its extreme lower left grid cell.

prec

number of digits when writing floating point values to ASCII grid files (only relevant if out.esri=TRUE).

esri.extension

extension for input/output ESRI grids: defaults to .asc for format="ascii", and to .flt for format="binary"

condensed.res

logical: return only results of the RSAGA geoprocessing function fun (condensed.res=TRUE), or include the results of the import and export operations, i.e. the calls to rsaga.esri.to.sgrd() and rsaga.sgrd.to.esri()? (see Value)

clean.up

logical: delete intermediate SAGA grid files?

intern

intern argument to be passed to rsaga.geoprocessor(); see Value

...

additional arguments for fun; NOTE: ESRI ASCII/float raster file names should NOT include the file extension (.asc, .flt); the file extension is defined by the esri.extension and format arguments!

Details

ESRI ASCII/float raster file names should NOT include the file extension (.asc, .flt); the file extension is defined by the esri.extension and format arguments!

Value

The object returned depends on the condensed.res arguments and the intern argument passed to the rsaga.geoprocessor().

If condensed.res=TRUE and intern=FALSE, a single numerical error code (0: success) is returned. If condensed.res=TRUE and intern=TRUE (default), a character vector with the module's console output is returned (invisibly).

If condensed.res=FALSE the result is a list with components in.res, geoproc.res and out.res. Each of these components is either an error code (for intern=FALSE) or (for intern=TRUE) a character vector with the console output of the input (rsaga.esri.to.sgrd()), the geoprocessing (fun), and the output conversion (rsaga.sgrd.to.esri()) step, respectively. For in.esri=FALSE or out.esri=FALSE, the corresponding component is NULL.

Note

Note that the intermediate grids as well as the output grids may overwrite existing files with the same file names without prompting the user. See example below.

See Also

rsaga.esri.to.sgrd(), rsaga.sgrd.to.esri(), rsaga.geoprocessor(), rsaga.env()

Examples

## Not run: 
rsaga.esri.wrapper(rsaga.hillshade,in.dem="dem",out.grid="hshd",condensed.res=FALSE,intern=FALSE)
# if successful, returns list(in.res=0,geoproc.res=0,out.res=0),
# and writes hshd.asc; intermediate files dem.sgrd, dem.hgrd, dem.sdat,
# hshd.sgrd, hshd.hgrd, and hshd.sdat are deleted.
# hshd.asc is overwritten if it already existed.

## End(Not run)

RSAGA documentation built on Dec. 10, 2022, 1:12 a.m.