Merge pull request #440 from MatMatt/master

[sextante] changed R command .libPaths to add and not substitute paths
This commit is contained in:
volaya 2013-02-25 12:32:59 -08:00
commit f3fa14ce87
2 changed files with 8 additions and 5 deletions

View File

@ -264,12 +264,14 @@ class RAlgorithm(GeoAlgorithm):
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\")");

View File

@ -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)