rsaga.env | R Documentation |
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.'
rsaga.env( path = NULL, modules = NULL, workspace = ".", cmd = ifelse(Sys.info()["sysname"] == "Windows", "saga_cmd.exe", "saga_cmd"), version = NULL, cores, parallel = FALSE, root = NULL, lib.prefix )
path |
path in which to find |
modules |
path in which to find SAGA libraries; see Details |
workspace |
path of the working directory for SAGA; defaults to the current directory ( |
cmd |
name of the SAGA command line program; defaults to |
version |
optional character string: SAGA GIS (API) version, e.g. |
cores |
optional numeric argument, or |
parallel |
optional logical argument (default: |
root |
optional root path to SAGA GIS installation. It is used if RSAGA performce a search for the SAGA command line program (s. |
lib.prefix |
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/SAGA-GIS
, C:/Program Files (x86)/SAGA-GIS
,C:/SAGA-GIS
, C:/OSGeo4W64/apps/saga-lts
or C:/OSGeo4W64/apps/saga
.
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 rsaga.env
:
No paths to the SAGA command line program and to the SAGA modules are specified by the user through the arguments path
and modules
.
On Windows rsaga.env
tries to find the SAGA command line program in the following folders
C:/Progra~1/SAGA
, C:/Progra~2/SAGA
, C:/Progra~1/SAGA-GIS
, C:/Progra~2/SAGA-GIS
, C:/SAGA-GIS
, C:/OSGeo4W64/apps/saga-lts
and C:/OSGeo4W64/apps/saga
.
If this fails and attempt is being made to find the SAGA command line program with a search on C:/
(The drive letter can be changed with the root
argument).
The subfolder 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 /usr
.
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 workspace
, cmd
, path
, modules
, version
, cores
and parallel
with values as passed to rsaga.env
or default values as described in the Details section.
Note that the default workspace
is "."
, not getwd()
; i.e. the default SAGA workspace folder is not fixed, it changes each time you change the R working directory using setwd
.
Alexander Brenning and Marc Becker
rsaga.get.version()
## 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_x.x.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.