set_env tries to find all the paths necessary to run QGIS from within R.

set_env(root = NULL, new = FALSE, dev = TRUE, ...)



Root path to the QGIS-installation. If left empty, the function looks for qgis.bat first in the most likely locations (C:/OSGEO4~1, C:/OSGEO4~2), and secondly on the C: drive under Windows. On a Mac, it looks for under "Applications" and "/usr/local/Cellar/". On Linux, set_env assumes that the root path is "/usr".


When called for the first time in an R session, set_env caches its output. Setting new to TRUE resets the cache when calling set_env again. Otherwise, the cached output will be loaded back into R even if you used new values for function arguments root and/or dev.


If set to TRUE, set_env will use the development version of QGIS (if available).


Currently not in use.


The function returns a list containing all the path necessary to run QGIS from within R. This is the root path, the QGIS prefix path and the path to the Python plugins.


# Letting set_env look for the QGIS installation might take a while depending
# on how full the C: drive is (Windows)
# It is much faster (0 sec) to explicitly state the root path to the QGIS
# installation
set_env("C:/OSGEO4~1")  # Windows example
# }