Description Usage Arguments Details Value Note Author(s) Examples
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.
1 2 |
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
|
NA_flag |
Value used for NAs when exporting raster objects through
|
qgis_env |
Environment containing all the paths to run the QGIS API. For
more information, refer to |
In detail, the function performs following actions and parameter-argument checks:
Were the right parameter names used?
Were the correct argument values provided?
The function collects all necessary arguments (to run QGIS) and
respective default values which were not set by the user with the help of
get_args_man()
.
If an argument value corresponds to a spatial object residing in R
(sp
-, sf
- or raster
-objects are supported), the function will save
the spatial object to tempdir()
, and use the corresponding file path to
replace the spatial object in the parameter-argument list. If the QGIS
geoalgorithm parameter belongs to the ParameterMultipleInput
-instance
class (see for example get_usage(grass7:v.patch)
) you may either use a
character-string containing the paths to the spatial objects separated by a
semi-colon (e.g., "shape1.shp;shape2.shp;shape3.shp" - see also QGIS documentation)
or provide a base::list()
where each spatial object corresponds to one
list element.
If a parameter accepts as arguments values from a selection, the
function replaces verbal input by the corresponding number (required by the
QGIS Python API). Please refer to the example section for more details, and
to get_options()
for valid options for a given geoalgorithm.
If GRASS_REGION_PARAMETER
is "None" (the QGIS default), run_qgis
will automatically determine the region extent based on the user-specified
input layers. If you do want to specify the GRASS_REGION_PARAMETER
yourself, please do it in accordance with the QGIS documentation,
i.e., use a character string and separate the coordinates with a comma:
"xmin, xmax, ymin, ymax".
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.
This function was inspired by rgrass7::doGRASS()
.
Jannes Muenchow
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.