pass_args: Specifying QGIS geoalgorithm parameters the R way

Description Usage Arguments Details Value Note Author(s) Examples

Description

The function lets the user specify QGIS geoalgorithm parameters as R named arguments or a a parameter-argument list. When omitting required parameters, defaults will be used if available as derived from get_args_man(). Additionally, the function checks thoroughly the user-provided parameters and arguments.

Usage

1
2
pass_args(alg, ..., params = NULL, NA_flag = -99999,
  qgis_env = set_env())

Arguments

alg

The name of the geoalgorithm to use.

...

Triple dots can be used to specify QGIS geoalgorithm arguments as R named arguments.

params

Parameter-argument list for a specific geoalgorithm, see get_args_man() for more details. Please note that you can either specify R arguments directly via the triple dots (see above) or via the parameter-argument list. However, you may not mix the two methods.

NA_flag

Value used for NAs when exporting raster objects through save_spatial_objects() (default: -99999).

qgis_env

Environment containing all the paths to run the QGIS API. For more information, refer to set_env().

Details

In detail, the function performs following actions and parameter-argument checks:

Value

The function returns the complete parameter-argument list for a given QGIS geoalgorithm. The list is constructed with the help of get_args_man() while considering the R named arguments or the params-parameter specified by the user as additional input. If available, the function returns the default values for all parameters which were not specified.

Note

This function was inspired by rgrass7::doGRASS().

Author(s)

Jannes Muenchow

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
data(dem, package = "RQGIS")
alg <- "grass7:r.slope.aspect"
get_usage(alg)
# 1. using R named arguments
pass_args(alg, elevation = dem, slope = "slope.asc")
# 2. doing the same with a parameter argument list
pass_args(alg, params = list(elevation = dem, slope = "slope.asc"))
# 3. verbal input replacement (note that "degrees" will be replaced by 0)
get_options(alg)
pass_args(alg, elevation = dem, format = "degrees")

## End(Not run)

RQGIS documentation built on May 2, 2019, 8:23 a.m.