Learn R Programming

Rsagacmd (version 0.0.9)

saga_gis: Initiate a SAGA-GIS geoprocessor object

Description

Dynamically generates functions to all valid SAGA-GIS libraries and tools. These functions are stored within a saga S3 object as a named list of functions

Usage

saga_gis(
  saga_bin = NULL,
  grid_caching = FALSE,
  grid_cache_threshold = 100,
  grid_cache_dir = NULL,
  cores = NULL,
  opt_lib = NULL,
  temp_path = NULL
)

Arguments

saga_bin

The path to saga_cmd executable. If this argument is not supplied then an automatic search for the saga_cmd executable will be performed.

grid_caching

A logical whether to use file caching in saga_cmd geoprocessing operations for rasters that are too large to fit into memory.

grid_cache_threshold

A number to act as a threshold (in Mb) before file caching is activated for loaded raster data.

grid_cache_dir

The path to directory for temporary files generated by file caching. If not provided then the result from `base::tempdir()` is used.

cores

An integer for the maximum number of processing cores. By default all cores are utilized. Needs to be set to 1 if file caching is activated.

opt_lib

A character vector with the names of a subset of SAGA-GIS libraries. Used to link only a subset of named SAGA-GIS tool libraries, rather than creating functions for all available tool libraries.

temp_path

The path to use to store any temporary files that are generated as data is passed between R and SAGA-GIS. If not specified, then the system `base::tempdir()` is used.

Value

A S3 `saga` object containing a nested list of functions for SAGA-GIS libraries and tools.

Examples

Run this code
# NOT RUN {
# Initialize a saga object
saga <- saga_gis()

# Alternatively intialize a saga object using file caching to handle large
# raster files
saga <- saga_gis(grid_caching = TRUE, grid_cache_threshold = 250, cores = 1)

# Example terrain analysis
# Generate a random DEM
dem <- saga$grid_calculus$random_terrain(radius = 100)

# Use Rsagacmd to calculate the Terrain Ruggedness Index
tri <- saga$ta_morphometry$terrain_ruggedness_index_tri(dem = dem)
plot(tri)

# Optionally run command and do not load result as an R object
saga$ta_morphometry$terrain_ruggedness_index_tri(dem = dem, .intern = FALSE)
# }

Run the code above in your browser using DataLab