I’ve tried to get QGIS and R playing together in the past, with only occasional success. The new SEXTANTE plugin for QGIS, which provides links into a number of applications including R, SAGA and GDAL, looks really promising.
Getting it working on Mac OSX was a little tricky, as there is a (known) bug in the plugin that hasn’t been resolved yet.
- Open up the python plugin directory for SEXTANTE:
- Make a backup copy of RUtils.py (command-D in the Finder);
- Open up RUtils.py in a text or code editor (I’m using Komodo edit these days and it’s working really well);
- On line 58, change:
command = ["R", "CMD", "BATCH", "--vanilla", RUtils.getRScriptFilename(), RUtils.getConsoleOutputFilename()
command = "R CMD BATCH --vanilla " + RUtils.getRScriptFilename() + " "+ RUtils.getConsoleOutputFilename()
- Save and restart QGIS.
While you can’t simply run an R script directly, you can create a
.rsx file either in an editor or directly with the SEXTANTE toolbox and use it. This is the Raster_histogram.rsx file from the examples:
##layer = raster
Giving, from a DEM layer in QGIS: