Showing with 8 additions and 5 deletions.
  1. +5 −3 python/plugins/sextante/r/RAlgorithm.py
  2. +3 −2 python/plugins/sextante/r/scripts/Advanced_Raster_histogram.rsx
8 changes: 5 additions & 3 deletions python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ def getExportCommands(self):
def getImportCommands(self):
commands = []
# if rgdal is not available, try to install it
# just use US mirror
commands.append('options("repos"="http://cran.us.r-project.org")')
# just use main mirror
commands.append('options("repos"="http://cran.at.r-project.org/")')
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
if not os.path.isdir(rLibDir):
os.mkdir(rLibDir)
commands.append('.libPaths("%s")' % rLibDir )
# .libPaths("%s") substitutes the personal libPath with "%s"! With '.libPaths(c("%s",deflibloc))' it is added without replacing and we can use all installed R packages!
commands.append('deflibloc <- .libPaths()[1]')
commands.append('.libPaths(c("%s",deflibloc))' % rLibDir )
commands.append(
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)
commands.append("library(\"rgdal\")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##[Example scripts]=group
##Layer = raster
##no_data_value = number 0
##breaks = number 100
##color = string red
##showplots
Layer <- raster(Layer, 1)
NAvalue(Layer) = no_data_value
hist(as.matrix(Layer), breaks=100, xlab = basename(filename(Layer)))
hist(Layer, breaks=breaks,col=color)