Description Usage Arguments Details Value Note Author(s) Examples
run_qgis() calls QGIS algorithms from within R while passing the
corresponding function arguments.
| 1 2 | 
| alg | Name of the GIS function to be used (see  | 
| ... | Triple dots can be used to specify QGIS geoalgorithm arguments as R
named arguments. For more details, please refer to  | 
| params | Parameter-argument list for a specific geoalgorithm. Please note
that you can either specify R named arguments directly via the triple dots
(see above) or via a parameter-argument list. However, you may not mix the
two methods. See the example section,  | 
| load_output | If  | 
| show_output_paths | Logical. QGIS computes all possible output files for
a given geoalgorithm, and saves them to a temporary location in case the
user has not specified explicitly another output location. Setting
 | 
| 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  | 
This workhorse function calls the QGIS Python API, and specifically
processing.runalg().
The function prints a list (named according to the output parameters)
containing the paths to the files created by QGIS. If not otherwise
specified, the function saves the QGIS generated output files to a temporary
folder (created by QGIS). Optionally, function parameter load_output loads
spatial QGIS output (vector and raster data) into R.
Please note that one can also pass spatial R objects as input parameters
where suitable (e.g., input layer, input raster). Supported formats are
sp::SpatialPointsDataFrame()-, sp::SpatialLinesDataFrame()-,
sp::SpatialPolygonsDataFrame()-, sf::sf()- (of class sf, sfc as well
as sfg), and raster::raster()-objects. See the example section for more
details.
GRASS users do not have to specify manually the GRASS region extent
(function argument GRASS_REGION_PARAMETER). If "None" (the QGIS default),
run_qgis() (see pass_args() for more details) will automatically determine
the region extent based on the user-specified input layers. If you do want
to specify it 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".
Jannes Muenchow, Victor Olaya, QGIS core team
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run: 
# calculate the slope of a DEM
# load dem - a raster object
data(dem, package = "RQGIS3")
# find out the name of a GRASS function with which to calculate the slope
find_algorithms(search_term = "grass7.*slope")
# find out how to use the function
alg = "grass7:r.slope.aspect"
get_usage(alg)
# 1. run QGIS using R named arguments, and load the QGIS output back into R
slope = run_qgis(alg, elevation = dem, slope = "slope.asc",
                  load_output = TRUE)
# 2. doing the same with a parameter-argument list
params = list(elevation = dem, slope = "slope.asc")
slope = run_qgis(alg, params = params, load_output = TRUE)
# 3. calculate the slope, the aspect and the pcurvature.
terrain = run_qgis(alg, elevation = dem, slope = "slope.asc",
                    aspect = "aspect.asc", pcurvature = "pcurv.asc",
                    load_output = TRUE)
# the three output rasters are returned in a list of length 3
terrain
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.