rsaga.env creates a list with system-dependent information on SAGA path, module path and data (working) directory. This kind of a list is required by most RSAGA geoprocessing functions and is referred to as the 'RSAGA geoprocessing environment.'
1 2 3 4
path in which to find
path in which to find SAGA libraries; see Details
path of the working directory for SAGA; defaults to the current directory (
name of the SAGA command line program; defaults to
optional character string: SAGA GIS (API) version, e.g.
optional numeric argument, or
optional logical argument (default:
optional root path to SAGA GIS installation. It is used if RSAGA performce a search for the SAGA command line program (s.
character string: a possible (platform-dependent) prefix for SAGA GIS library names; if missing (recommended), a call to
IMPORTANT: Unlike R functions such as
options(), which changes and saves settings somewhere in a global variable,
rsaga.env() does not actually 'save' any settings, it simply creates a list that can (and has to) be passed to other
rsaga.* functions. See example below.
We strongly recommend to install SAGA GIS on Windows in
C:/Program Files (x86)/SAGA-GIS,
If you use a standalone version of SAGA GIS in a different path, please refer to section 2 bellow.
There are three ways to create a RSAGA environment with
No paths to the SAGA command line program and to the SAGA modules are specified by the user through the arguments
rsaga.env tries to find the SAGA command line program in the following folders
If this fails and attempt is being made to find the SAGA command line program with a search on
(The drive letter can be changed with the
tools (SAGA Version < 3.0.0 subfolder
modules) is checked for the SAGA module libraries.
On Unix systems
rsaga.env tries to find the SAGA command line program in various default paths.
Additionally, on Unix systems the PATH environment variable is checked for the path to the SAGA command line program
and the SAGA_MLB environment variable is checked for the SAGA module libraries.
If this fails, a search for the SAGA command line program and the module libraries is performed on
If no SAGA command line program can be found, please specify the paths as described in section 2.
The user specifies both the path to the SAGA command line program and to the SAGA module libraries. Both paths are checked if they are valid. Use this if SAGA GIS is located in a non-standard path or if you use more than one SAGA GIS version.
The user specifies only the path to the SAGA command line program. A search for the SAGA modules is performed as described in section 1.
A list with components
parallel with values as passed to
rsaga.env or default values as described in the Details section.
Note that the default
getwd(); i.e. the default SAGA workspace folder is not fixed, it changes each time you change the R working directory using
Alexander Brenning and Marc Becker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Not run: # Check the default RSAGA environment on your computer: myenv <- rsaga.env() myenv # SAGA data in C:/sagadata, binaries in C:/SAGA-GIS, modules in C:/SAGA-GIS/modules: myenv <- rsaga.env(workspace="C:/sagadata", path="C:/SAGA-GIS") # Unix: SAGA in /usr/bin (instead of the default /usr/local/bin), # and modules in /use/lib/saga: # myenv <- rsaga.env(path="/usr/bin") # Use the 'myenv' environment for SAGA geoprocessing: rsaga.hillshade("dem","hillshade",env=myenv) # ...creates (or overwrites) grid "C:/sagadata/hillshade.sgrd" # derived from digital elevation model "C:/sagadata/dem.sgrd" # Same calculation with different SAGA version: # (I keep several versions in SAGA-GIS_2.0.x folders:) myenv05 = rsaga.env(path = "C:/Progra~1/SAGA-GIS_2.0.5") rsaga.hillshade("dem","hillshade205",env=myenv05) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.