### Install QGIS and third-party providers Source: https://r-spatial.github.io/qgisprocess/articles/qgisprocess.html Prerequisite setup: install QGIS and third-party providers such as GRASS GIS and SAGA on your system to access and run all geoalgorithms provided through qgis_process from within R. ```text ``` ``` ``` -------------------------------- ### Load example data paths Source: https://r-spatial.github.io/qgisprocess/articles/qgis_expressions.html Sets up file paths to example GeoPackage files for a lake polygon and depth points. ```R longlake_path <- system.file("longlake/longlake.gpkg", package = "qgisprocess") longlake_depth_path <- system.file("longlake/longlake_depth.gpkg", package = "qgisprocess") ``` -------------------------------- ### Example: Detect qgis_process paths on Windows and macOS Source: https://r-spatial.github.io/qgisprocess/reference/qgis_detect_paths.html Example usage that calls qgis_detect_paths() and checks that the platform-specific function returns the same result. The example is conditional on the operating system. ```R if (.Platform$OS.type == "windows") { qgis_detect_paths() identical(qgis_detect_windows_paths(), qgis_detect_paths()) } if (Sys.info()["sysname"] == "Darwin") { qgis_detect_paths() identical(qgis_detect_macos_paths(), qgis_detect_paths()) } ``` -------------------------------- ### Install qgisprocess development version from GitHub Source: https://r-spatial.github.io/qgisprocess/index.html Installs the development version of qgisprocess from GitHub. The commented line installs the remotes package if needed. ```r # install.packages("remotes") remotes::install_github("r-spatial/qgisprocess") ``` -------------------------------- ### Example of qgis_tmp_base(), qgis_tmp_file(), qgis_tmp_vector(), qgis_tmp_raster() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_tmp_file.html Demonstrates the output of the temporary file functions. Each returns a character vector with a path to a not-yet-created file. The examples show the default extensions .csv, .gpkg, and .tif. ```r qgis_tmp_base() #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f" qgis_tmp_file(".csv") #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b3bbe22e4.csv" qgis_tmp_vector() #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b294b8c60.gpkg" qgis_tmp_raster() #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b36fcf98b.tif" ``` -------------------------------- ### Example: run native:buffer and extract OUTPUT Source: https://r-spatial.github.io/qgisprocess/reference/qgis_extract_output.html Runs the 'native:buffer' algorithm on a sample dataset and extracts the output element 'OUTPUT' using qgis_extract_output(). The example shows the printed result and the extracted output vector. ```r result <- qgis_run_algorithm( "native:buffer", INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"), DISTANCE = 10 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` # the print() method of a qgis_result only prints its output elements: result #> #> List of 1 #> $ OUTPUT: 'qgis_outputVector' chr "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b23488d0a.gpkg" # nevertheless, more elements are included: length(result) #> [1] 5 names(result) #> [1] "OUTPUT" ".algorithm" ".args" ".raw_json_input" #> [5] ".processx_result" # extract the output element 'OUTPUT': qgis_extract_output(result) #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b23488d0a.gpkg" #> attr(,"class") #> [1] "qgis_outputVector" ``` -------------------------------- ### Example: Convert QGIS result to stars object Source: https://r-spatial.github.io/qgisprocess/reference/st_as_stars.html Example showing how to run a QGIS algorithm and convert the result to a stars or stars_proxy object using st_as_stars(). The example is not run during R CMD check to save time. It demonstrates the most direct approach and an alternative that extracts the output element first. ```r # \donttest{ # not running below examples in R CMD check to save time result <- qgis_run_algorithm( "native:slope", INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess") ) #> Argument `Z_FACTOR` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_raster()` # most direct approach, autoselecting a `qgis_outputRaster` type # output from the `result` object and reading as stars or stars_proxy: stars::st_as_stars(result) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #> Min. 1st Qu. Median Mean 3rd Qu. #> file2f7b10394d10.tif 0.008276554 0.2864364 0.4271587 0.4269891 0.5803983 #> Max. NA's #> file2f7b10394d10.tif 0.8075118 6475 #> dimension(s): #> from to offset delta refsys point x/y #> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x] #> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y] stars::st_as_stars(result, proxy = TRUE) #> stars_proxy object with 1 attribute in 1 file(s): #> $file2f7b10394d10.tif #> [1] "[...]/file2f7b10394d10.tif" #> #> dimension(s): #> from to offset delta refsys point x/y #> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x] #> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y] # if you need more control, extract the needed output element first: output_raster <- qgis_extract_output(result, "OUTPUT") stars::st_as_stars(output_raster) #> stars object with 2 dimensions and 1 attribute #> attribute(s): #> Min. 1st Qu. Median Mean 3rd Qu. #> file2f7b10394d10.tif 0.008276554 0.2864364 0.4271587 0.4269891 0.5803983 #> Max. NA's #> file2f7b10394d10.tif 0.8075118 6475 #> dimension(s): #> from to offset delta refsys point x/y #> x 1 100 409940 18.27 NAD83 / UTM zone 20N FALSE [x] #> y 1 100 5084861 -15.54 NAD83 / UTM zone 20N FALSE [y] # } ``` -------------------------------- ### Examples for qgis_get_description, qgis_get_argument_specs, qgis_get_output_specs, and qgis_show_help Source: https://r-spatial.github.io/qgisprocess/reference/qgis_show_help.html Demonstrates the functions using the 'native:filedownloader' algorithm. The first call returns a description string. The argument and output specs return tibbles. The show_help call prints detailed help and returns the algorithm name invisibly. The examples are wrapped in \donttest{} to avoid running during R CMD check. ```r qgis_get_description("native:filedownloader") #> native:filedownloader #> "Downloads a URL to the file system with an HTTP(S) GET or POST request.\nThis algorithm downloads a URL to the file system with an HTTP(S) GET or POST request" # \donttest{ # not running below examples in R CMD check to save time qgis_get_argument_specs("native:filedownloader") #> # A tibble: 4 × 6 #> name description qgis_type default_value available_values acceptable_values #> #> 1 URL URL string #> 2 METHOD Method enum #> 3 DATA Data string #> 4 OUTPUT File destin… fileDest… qgis_get_output_specs("native:filedownloader") #> # A tibble: 1 × 3 #> name description qgis_output_type #> #> 1 OUTPUT File destination outputFile qgis_show_help("native:filedownloader") #> Download file via HTTP(S) (native:filedownloader) #> #> ---------------- #> Description #> ---------------- #> Downloads a URL to the file system with an HTTP(S) GET or POST request. #> This algorithm downloads a URL to the file system with an HTTP(S) GET or POST request #> #> ---------------- #> Arguments #> ---------------- #> #> URL: URL #> Argument type: string #> Acceptable values: #> - String value #> - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field #> - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression #> METHOD: Method #> Default value: 0 #> The HTTP method to use for the request #> Argument type: enum #> Available values: #> - 0: GET #> - 1: POST #> Acceptable values: #> - Number of selected option, e.g. '1' #> - Comma separated list of options, e.g. '1,3' #> DATA: Data (optional) #> The data to add in the body if the request is a POST #> Argument type: string #> Acceptable values: #> - String value #> - field:FIELD_NAME to use a data defined value taken from the FIELD_NAME field #> - expression:SOME EXPRESSION to use a data defined value calculated using a custom QGIS expression #> OUTPUT: File destination #> Argument type: fileDestination #> Acceptable values: #> - Path for new file #> #> ---------------- #> Outputs #> ---------------- #> #> OUTPUT: #> File destination #> #> #> # } ``` -------------------------------- ### Convert qgis_result to terra with qgis_as_terra examples Source: https://r-spatial.github.io/qgisprocess/reference/qgis_as_terra.html Complete example block from the documentation. It runs `qgis_run_algorithm()` for a slope raster and a buffer vector, then demonstrates coercing the result or extracted output to `SpatRaster`, `SpatVector`, and `SpatVectorProxy` (with `proxy = TRUE`). The block is wrapped in `\donttest{}` and includes console output showing default argument messages and printed object summaries. Note the example is not executed during R CMD check to save time. ```r # \donttest{ # not running below examples in R CMD check to save time result <- qgis_run_algorithm( "native:slope", INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess") ) #> Argument `Z_FACTOR` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_raster()` # most direct approach, autoselecting a `qgis_outputRaster` type # output from the `result` object and reading as SpatRaster: qgis_as_terra(result) #> class : SpatRaster #> size : 100, 100, 1 (nrow, ncol, nlyr) #> resolution : 18.27273, 15.53535 (x, y) #> extent : 409939.9, 411767.1, 5083307, 5084861 (xmin, xmax, ymin, ymax) #> coord. ref. : NAD83 / UTM zone 20N (EPSG:26920) #> source : file2f7b3bc66bd6.tif #> name : file2f7b3bc66bd6 # if you need more control, extract the needed output element first: output_raster <- qgis_extract_output(result, "OUTPUT") qgis_as_terra(output_raster) #> class : SpatRaster #> size : 100, 100, 1 (nrow, ncol, nlyr) #> resolution : 18.27273, 15.53535 (x, y) #> extent : 409939.9, 411767.1, 5083307, 5084861 (xmin, xmax, ymin, ymax) #> coord. ref. : NAD83 / UTM zone 20N (EPSG:26920) #> source : file2f7b3bc66bd6.tif #> name : file2f7b3bc66bd6 # Same holds for coercion to SpatVector result2 <- qgis_run_algorithm( "native:buffer", INPUT = system.file("longlake/longlake.gpkg", package = "qgisprocess"), DISTANCE = 100 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` qgis_as_terra(result2) #> class : SpatVector #> geometry : polygons #> dimensions : 1, 1 (geometries, attributes) #> extent : 409850.6, 411856.3, 5083216, 5084951 (xmin, xmax, ymin, ymax) #> source : file2f7b73d043d6.gpkg #> coord. ref. : NAD83 / UTM zone 20N (EPSG:26920) #> names : label #> type : #> values : Long Lake output_vector <- qgis_extract_output(result2, "OUTPUT") qgis_as_terra(output_vector) #> class : SpatVector #> geometry : polygons #> dimensions : 1, 1 (geometries, attributes) #> extent : 409850.6, 411856.3, 5083216, 5084951 (xmin, xmax, ymin, ymax) #> source : file2f7b73d043d6.gpkg #> coord. ref. : NAD83 / UTM zone 20N (EPSG:26920) #> names : label #> type : #> values : Long Lake # SpatVectorProxy: qgis_as_terra(result2, proxy = TRUE) #> class : SpatVectorProxy #> geometry : polygons #> dimensions : 1, 1 (geometries, attributes) #> extent : 409850.6, 411856.3, 5083216, 5084951 (xmin, xmax, ymin, ymax) #> source : file2f7b73d043d6.gpkg #> coord. ref. : NAD83 / UTM zone 20N (EPSG:26920) #> names : label #> type : # } ``` -------------------------------- ### Examples of qgis_path() and qgis_version() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_path.html Demonstrates calling qgis_path() and qgis_version() with various arguments and shows the resulting output, including the debug output with detailed version information. ```r qgis_path() #> [1] "qgis_process" qgis_path(quiet = FALSE) #> Using 'qgis_process' in the system PATH. #> >>> If you need another installed QGIS instance, run `qgis_configure()`; #> see `?qgis_configure` if you need to preset the path of 'qgis_process'. #> [1] "qgis_process" qgis_version() #> [1] "3.44.7-Solothurn" qgis_version(full = FALSE) #> [1] "3.44.7" qgis_version(debug = TRUE) #> [1] "3.44.7-Solothurn" #> #> Using qgisprocess 0.4.2.9000 #> #> Versions reported by 'qgis_process': #> ------------------------------------ #> QGIS 3.44.7-Solothurn 'Solothurn' (ea262bc5ed8) #> QGIS code revision ea262bc5ed8 #> Qt version 5.15.13 #> Python version 3.12.3 #> GDAL/OGR version 3.8.4 #> PROJ version 9.4.0 #> EPSG Registry database version v11.004 (2024-02-24) #> GEOS version 3.12.1-CAPI-1.18.1 #> SQLite version 3.45.1 #> OS Ubuntu 24.04.3 LTS ``` -------------------------------- ### Examples of qgis_list_input and qgis_dict_input Source: https://r-spatial.github.io/qgisprocess/reference/qgis_list_input.html Demonstrates creating an unnamed list with qgis_list_input and a named list with qgis_dict_input, showing the resulting objects and their classes. ```R qgis_list_input(1, 2, 3) #> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 3 #> #> attr(,"class") #> [1] "qgis_list_input" qgis_dict_input(a = 1, b = 2, c = 3) #> $a #> [1] 1 #> #> $b #> [1] 2 #> #> $c #> [1] 3 #> #> attr(,"class") #> [1] "qgis_dict_input" ``` -------------------------------- ### Install qgisprocess from CRAN Source: https://r-spatial.github.io/qgisprocess/index.html Installs the latest CRAN release of the qgisprocess package. ```r install.packages("qgisprocess") ``` -------------------------------- ### Example: search algorithms with regex and provider filter Source: https://r-spatial.github.io/qgisprocess/reference/qgis_search_algorithms.html Example call to qgis_search_algorithms() that filters by algorithm pattern "point.*line" and provider "^native$". The output is a tibble with 4 rows showing matching algorithms and their titles. ```r qgis_search_algorithms( algorithm = "point.*line", provider = "^native$" ) #> # A tibble: 4 × 5 #> provider provider_title group algorithm algorithm_title #> #> 1 native QGIS (native c++) Check geometry native:checkgeomet… Points outside… #> 2 native QGIS (native c++) Vector geometry native:interpolate… Interpolate po… #> 3 native QGIS (native c++) Vector geometry native:pointsalong… Points along g… #> 4 native QGIS (native c++) Vector creation native:randompoint… Random points … ``` -------------------------------- ### Set QGIS path and configure qgisprocess on Windows Source: https://r-spatial.github.io/qgisprocess/articles/qgisprocess.html Sets the path to the QGIS installation on Windows, with an optional commented line for the QGIS nightly version installed via OSGeo4W. Run qgis_configure() (or load the package with library(qgisprocess)) to apply the path. ```r # specify path to QGIS installation on Windows options(qgisprocess.path = "C:/Program Files/QGIS 3.28/bin/qgis_process-qgis.bat") # or use the QGIS nightly version (if installed via OSGeo4W) # options(qgisprocess.path = "C:/OSGeo4W64/bin/qgis_process-qgis-dev.bat") qgis_configure() # or use library(qgisprocess) if package was not loaded yet ``` -------------------------------- ### qgis_detect_paths() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Detects QGIS installations with 'qgis_process'. ```APIDOC ## qgis_detect_paths() ### Description Detects QGIS installations with 'qgis_process'. ### Usage qgis_detect_paths() ### Value A character vector of detected paths. ``` -------------------------------- ### qgis_enable_plugins example with unknown plugin Source: https://r-spatial.github.io/qgisprocess/reference/qgis_enable_plugins.html Example call to qgis_enable_plugins() with a plugin name that is not recognized by the package. The output shows the warning 'Ignoring unknown plugins: name_of_plugin' and the message 'No QGIS plugins to be handled; exiting.' indicating that the plugin was not processed. ```r qgis_enable_plugins("name_of_plugin") #> Ignoring unknown plugins: name_of_plugin #> No QGIS plugins to be handled; exiting. ``` -------------------------------- ### Example: qgis_unconfigure() and qgis_configure(use_cached_data = TRUE) Source: https://r-spatial.github.io/qgisprocess/reference/qgis_unconfigure.html Example from the documentation. The first block shows qgis_unconfigure() wrapped in a dontrun block because it clears the cache environment. The second block shows how to repopulate the cache using qgis_configure(use_cached_data = TRUE), with the expected output displayed. ```r if (FALSE) { # \dontrun{ # not running this function in example() as it clears the cache environment. qgis_unconfigure() } # } ``` ```r # undoing qgis_unconfigure() by repopulating the cache environment from file: # \donttest{ # not running in R CMD check to save time qgis_configure(use_cached_data = TRUE) #> Checking configuration in cache file (/home/runner/.cache/R-qgisprocess/cache-0.4.2.9000.rds) #> Checking cached QGIS version with version reported by 'qgis_process' ... #> QGIS versions match! (3.44.7-Solothurn) #> Checking cached QGIS plugins (and state) with those reported by 'qgis_process' ... #> QGIS plugins match! (0 processing provider plugin(s) enabled) #> #> >>> Run `qgis_enable_plugins()` to enable 3 disabled plugins and access #> their algorithms: grassprovider, processing, #> processing_saga_nextgen #> #> Restoring configuration from '/home/runner/.cache/R-qgisprocess/cache-0.4.2.9000.rds' #> QGIS version: 3.44.7-Solothurn #> Using 'qgis_process' in the system PATH. #> >>> If you need another installed QGIS instance, run `qgis_configure()`; #> see `?qgis_configure` if you need to preset the path of 'qgis_process'. #> Using JSON for output serialization. #> Using JSON for input serialization. #> 0 out of 3 available processing provider plugins are enabled. #> Having access to 409 algorithms from 4 QGIS processing providers. #> Use qgis_algorithms(), qgis_providers(), qgis_plugins(), qgis_path() and #> qgis_version() to inspect the cache environment. # } ``` -------------------------------- ### Example: Check JSON input and output usage Source: https://r-spatial.github.io/qgisprocess/reference/qgis_using_json_input.html Calls qgis_using_json_input() and qgis_using_json_output() to check whether JSON methods are used. The expected output is TRUE for both. ```r qgis_using_json_input() #> [1] TRUE qgis_using_json_output() #> [1] TRUE ``` -------------------------------- ### Example: Convert qgis_result and qgis_outputRaster to RasterLayer Source: https://r-spatial.github.io/qgisprocess/reference/qgis_as_raster.html Demonstrates converting a qgis_result object from qgis_run_algorithm() to a RasterLayer using qgis_as_raster(), and also shows extracting the output element first with qgis_extract_output() before conversion. The example is wrapped in \donttest{} and not run in R CMD check to save time. ```r # \donttest{ # not running below examples in R CMD check to save time result <- qgis_run_algorithm( "native:slope", INPUT = system.file("longlake/longlake_depth.tif", package = "qgisprocess") ) #> Argument `Z_FACTOR` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_raster()` # most direct approach, autoselecting a `qgis_outputRaster` type # output from the `result` object and reading as RasterLayer: qgis_as_raster(result) #> class : RasterLayer #> dimensions : 100, 100, 10000 (nrow, ncol, ncell) #> resolution : 18.27273, 15.53535 (x, y) #> extent : 409939.9, 411767.1, 5083307, 5084861 (xmin, xmax, ymin, ymax) #> crs : +proj=utm +zone=20 +datum=NAD83 +units=m +no_defs #> source : file2f7b46faad02.tif #> names : file2f7b46faad02 #> # if you need more control, extract the needed output element first: output_raster <- qgis_extract_output(result, "OUTPUT") qgis_as_raster(output_raster) #> class : RasterLayer #> dimensions : 100, 100, 10000 (nrow, ncol, ncell) #> resolution : 18.27273, 15.53535 (x, y) #> extent : 409939.9, 411767.1, 5083307, 5084861 (xmin, xmax, ymin, ymax) #> crs : +proj=utm +zone=20 +datum=NAD83 +units=m +no_defs #> source : file2f7b46faad02.tif #> names : file2f7b46faad02 #> # } ``` -------------------------------- ### Reconfigure qgisprocess with qgis_configure() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_configure.html Run qgis_configure() without arguments to perform a full reconfiguration, rewriting the package cache file. This is not run in examples because it modifies the cache. ```r if (FALSE) { # \dontrun{ # package reconfiguration # (not run in example() as it rewrites the package cache file) qgis_configure() } # } ``` -------------------------------- ### Search QGIS algorithms with qgis_search_algorithms() Source: https://r-spatial.github.io/qgisprocess/index.html Searches for QGIS algorithms by name and group using regex. The example filters for 'buffer' in vector or features groups and returns a tibble with matching algorithms. ```r qgis_search_algorithms(algorithm = "buffer", group = "[Vv]ector|[Ff]eatures") #> # A tibble: 10 × 5 #> provider provider_title group algorithm algorithm_title #> #> 1 gdal GDAL Vector geoprocessing gdal:bufferv… Buffer vectors #> 2 gdal GDAL Vector geoprocessing gdal:oneside… One side buffer #> 3 grass GRASS Vector (v.*) grass:v.buff… v.buffer #> 4 native QGIS (native c++) Vector geometry native:buffer Buffer #> 5 native QGIS (native c++) Vector geometry native:buffe… Variable width… #> 6 native QGIS (native c++) Vector geometry native:multi… Multi-ring buf… #> 7 native QGIS (native c++) Vector geometry native:singl… Single sided b… #> 8 native QGIS (native c++) Vector geometry native:taper… Tapered buffers #> 9 native QGIS (native c++) Vector geometry native:wedge… Create wedge b… #> 10 sagang SAGA Next Gen Features sagang:featu… Features Buffer ``` -------------------------------- ### Example: Running native:buffer with qgis_run_algorithm_p() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_run_algorithm_p.html Demonstrates using qgis_run_algorithm_p() in a pipeline with system.file() to buffer a sample GeoPackage. The output shows default argument messages and the resulting qgis_result object with an OUTPUT path. ```r system.file( "longlake/longlake_depth.gpkg", package = "qgisprocess" ) |> qgis_run_algorithm_p( "native:buffer", DISTANCE = 10 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` #> #> List of 1 #> $ OUTPUT: 'qgis_outputVector' chr "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b2e09d08f.gpkg" ``` -------------------------------- ### Show help for QGIS algorithm with qgis_show_help() Source: https://r-spatial.github.io/qgisprocess/index.html Displays the help documentation for the specified QGIS algorithm, here 'native:buffer'. ```r qgis_show_help("native:buffer") ``` -------------------------------- ### qgis_version() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the version of QGIS. ```APIDOC ## qgis_version() ### Description Gets the version of QGIS. ### Usage qgis_version() ### Value A character string with the version. ``` -------------------------------- ### Load qgisprocess and view startup messages Source: https://r-spatial.github.io/qgisprocess/articles/qgisprocess.html Loads the qgisprocess package and shows the expected startup messages, including the QGIS version, the number of algorithms and providers, and a hint to run qgis_configure() to reload the cache. Also warns about disabled plugins that can be enabled with qgis_enable_plugins(). ```r library("qgisprocess") #> QGIS version: 3.44.7-Solothurn #> Having access to 409 algorithms from 4 QGIS processing providers. #> Run `qgis_configure(use_cached_data = TRUE)` to reload cache and get more details. #> >>> Run `qgis_enable_plugins()` to enable 3 disabled plugins and access #> their algorithms: grassprovider, processing, #> processing_saga_nextgen ``` -------------------------------- ### qgis_detect_windows_paths() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Detects QGIS installations on Windows. ```APIDOC ## qgis_detect_windows_paths() ### Description Detects QGIS installations on Windows. ### Usage qgis_detect_windows_paths() ### Value A character vector of detected paths. ``` -------------------------------- ### Example: buffer a vector layer with qgis_run_algorithm() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_run_algorithm.html Runs the 'native:buffer' algorithm on a sample GeoPackage with a distance of 10. The output shows messages about unspecified arguments using QGIS defaults and the resulting output vector file path. ```r qgis_run_algorithm( "native:buffer", INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"), DISTANCE = 10 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` #> #> List of 1 #> $ OUTPUT: 'qgis_outputVector' chr "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b5431fc4a.gpkg" ``` -------------------------------- ### qgis_result_status() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the status of a qgis_result object. ```APIDOC ## qgis_result_status() ### Description Gets the status of a qgis_result object. ### Usage qgis_result_status(result) ### Arguments - **result** (qgis_result) - Required - The result object. ### Value An integer status code. ``` -------------------------------- ### Run a QGIS algorithm with qgis_run_algorithm() Source: https://r-spatial.github.io/qgisprocess/articles/qgisprocess.html Run a QGIS algorithm from R using qgis_run_algorithm(). The example buffers the 'random_points' dataset from spDataLarge with a distance of 50. Unspecified arguments are reported and default values are used. The result is a qgis_result object containing the output filepath. ```R # if needed, first install spDataLarge: # remotes::install_github("Nowosad/spDataLarge") data("random_points", package = "spDataLarge") result <- qgis_run_algorithm("native:buffer", INPUT = random_points, DISTANCE = 50) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` ``` -------------------------------- ### qgis_path() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the path to the 'qgis_process' command. ```APIDOC ## qgis_path() ### Description Gets the path to the 'qgis_process' command. ### Usage qgis_path() ### Value A character string with the path. ``` -------------------------------- ### Usage of qgis_path() and qgis_version() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_path.html Shows the function signatures for qgis_path() and qgis_version() with their default arguments. ```r qgis_path(query = FALSE, quiet = TRUE) qgis_version(query = FALSE, quiet = TRUE, full = TRUE, debug = FALSE) ``` -------------------------------- ### qgis_get_description() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the description of a specific QGIS algorithm. ```APIDOC ## qgis_get_description() ### Description Gets the description of a specific QGIS algorithm. ### Usage qgis_get_description(algorithm) ### Arguments - **algorithm** (character) - Required - The algorithm identifier. ### Value A character string with the algorithm description. ``` -------------------------------- ### Run qgis_process --help and display output Source: https://r-spatial.github.io/qgisprocess/reference/qgis_run.html Calls qgis_run() with the argument '--help' to retrieve the command's help text, then prints the standard output. The output shows the QGIS Processing Executor version and usage information. ```r processx_list <- qgis_run(args = "--help") cat(processx_list$stdout) #> QGIS Processing Executor - 3.44.7-Solothurn 'Solothurn' (3.44.7-Solothurn) #> Usage: /usr/bin/qgis_process.bin [--help] [--version] [--json] [--verbose] [--no-python] [--skip-loading-plugins] [command] [algorithm id, path to model file, or path to Python script] [parameters] #> #> Options: #> --help or -h Output the help #> --version or -v Output all versions related to QGIS Process #> --json Output results as JSON objects #> --verbose Output verbose logs #> --no-python Disable Python support (results in faster startup) #> --skip-loading-plugins Avoid loading enabled plugins (results in faster startup) #> Available commands: #> plugins list available and active plugins #> plugins enable enables an installed plugin. The plugin name must be specified, e.g. "plugins enable cartography_tools" #> plugins disable disables an installed plugin. The plugin name must be specified, e.g. "plugins disable cartography_tools" #> list list all available processing algorithms #> help show help for an algorithm. The algorithm id or a path to a model file must be specified. #> run runs an algorithm. The algorithm id or a path to a model file and parameter values must be specified. Parameter values are specified after -- with PARAMETER=VALUE syntax. Ordered list values for a parameter can be created by specifying the parameter multiple times, e.g. --LAYERS=layer1.shp --LAYERS=layer2.shp #> Alternatively, a '-' character in place of the parameters argument indicates that the parameters should be read from STDIN as a JSON object. The JSON should be structured as a map containing at least the "inputs" key specifying a map of input parameter values. This implies the --json option for output as a JSON object. #> If required, the ellipsoid to use for distance and area calculations can be specified via the "--ELLIPSOID=name" argument. #> If required, an existing QGIS project to use during the algorithm execution can be specified via the "--PROJECT_PATH=path" argument. #> When passing parameters as a JSON object from STDIN, these extra arguments can be provided as an "ellipsoid" and a "project_path" key respectively. ``` -------------------------------- ### qgis_show_help() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Displays help information for a specific QGIS algorithm. ```APIDOC ## qgis_show_help() ### Description Displays help information for a specific QGIS algorithm. ### Usage qgis_show_help(algorithm) ### Arguments - **algorithm** (character) - Required - The algorithm identifier. ### Value Prints help information to the console. ``` -------------------------------- ### qgis_get_output_specs() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the output specifications for a specific QGIS algorithm. ```APIDOC ## qgis_get_output_specs() ### Description Gets the output specifications for a specific QGIS algorithm. ### Usage qgis_get_output_specs(algorithm) ### Arguments - **algorithm** (character) - Required - The algorithm identifier. ### Value A list or data frame with output specifications. ``` -------------------------------- ### Example: Run algorithm and extract result metadata Source: https://r-spatial.github.io/qgisprocess/reference/qgis_result_status.html Runs the native:buffer algorithm on a sample dataset, then extracts the exit status, standard output, standard error, and arguments. The output shows the status is 0, the stdout contains JSON details, stderr is empty, and args lists the input parameters. ```R result <- qgis_run_algorithm( "native:buffer", INPUT = system.file("longlake/longlake_depth.gpkg", package = "qgisprocess"), DISTANCE = 10 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` qgis_result_status(result) #> [1] 0 stdout <- qgis_result_stdout(result) cat(substr(stdout, 1, 335)) #> { #> "algorithm_details": { #> "can_cancel": true, #> "deprecated": false, #> "documentation_flags": [ #> "regenerates_primary_key_in_some_scenarios" #> ], #> "group": "Vector geometry", #> "has_known_issues": false, #> "help_url": null, #> "id": "native:buffer", #> "name": "Buffer", #> "requires_matching_crs": false, #> qgis_result_stderr(result) #> [1] "" qgis_result_args(result) #> $INPUT #> [1] "/home/runner/work/_temp/Library/qgisprocess/longlake/longlake_depth.gpkg" #> #> $DISTANCE #> [1] 10 #> #> $END_CAP_STYLE #> [1] 0 #> #> $JOIN_STYLE #> [1] 0 #> #> $OUTPUT #> [1] "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b25a45634.gpkg" #> ``` -------------------------------- ### qgis_get_argument_specs() Source: https://r-spatial.github.io/qgisprocess/reference/index.html Gets the argument specifications for a specific QGIS algorithm. ```APIDOC ## qgis_get_argument_specs() ### Description Gets the argument specifications for a specific QGIS algorithm. ### Usage qgis_get_argument_specs(algorithm) ### Arguments - **algorithm** (character) - Required - The algorithm identifier. ### Value A list or data frame with argument specifications. ``` -------------------------------- ### Create and run a wrapper function with qgis_function() Source: https://r-spatial.github.io/qgisprocess/reference/qgis_function.html Creates a callable function for the "native:buffer" algorithm and runs it on a sample GeoPackage. The output shows default argument messages and the resulting temporary vector file path. ```R qgis_buffer <- qgis_function("native:buffer") qgis_buffer( system.file( "longlake/longlake_depth.gpkg", package = "qgisprocess" ), DISTANCE = 10 ) #> Argument `SEGMENTS` is unspecified (using QGIS default value). #> Using `END_CAP_STYLE = "Round"` #> Using `JOIN_STYLE = "Round"` #> Argument `MITER_LIMIT` is unspecified (using QGIS default value). #> Argument `DISSOLVE` is unspecified (using QGIS default value). #> Argument `SEPARATE_DISJOINT` is unspecified (using QGIS default value). #> Using `OUTPUT = qgis_tmp_vector()` #> #> List of 1 #> $ OUTPUT: 'qgis_outputVector' chr "/tmp/RtmpKw9qpv/file2f7b748d365f/file2f7b57bf3e53.gpkg" ``` -------------------------------- ### Enable GRASS and SAGA Next Generation plugins Source: https://r-spatial.github.io/qgisprocess/articles/qgisprocess.html Enables the 'grassprovider' and 'processing_saga_nextgen' plugins required for GRASS GIS and SAGA workflows. Requires GRASS GIS and SAGA version > 7 installed, plus the third-party 'SAGA Next Generation' plugin installed in the QGIS GUI. ```r qgis_enable_plugins(c("grassprovider", "processing_saga_nextgen")) ``` -------------------------------- ### has_qgis() Source: https://r-spatial.github.io/qgisprocess/reference/has_qgis.html Checks whether the loaded qgisprocess cache is populated, indicating that a QGIS installation was accessible and responsive when loading the package. ```APIDOC ## has_qgis() ### Description Checks whether the loaded qgisprocess cache is populated, which means that a QGIS installation was accessible and responsive when loading the package. ### Usage ```r has_qgis() ``` ### Arguments None. ### Value A logical, with length 1. ### Examples ```r has_qgis() #> [1] TRUE ``` ```