Skip to content

Commit aa4b291

Browse files
committedFeb 25, 2013
changed the R command behavior .libPaths() in RAlgorithm.py to add a .lib.loc and not substitute one
modifies the Advanced_Raster_histogramm.rsx in order to fully benefit from raster package RAM savety
1 parent f85d3ae commit aa4b291

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
 

‎python/plugins/sextante/r/RAlgorithm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,14 @@ def getExportCommands(self):
264264
def getImportCommands(self):
265265
commands = []
266266
# if rgdal is not available, try to install it
267-
# just use US mirror
268-
commands.append('options("repos"="http://cran.us.r-project.org")')
267+
# just use main mirror
268+
commands.append('options("repos"="http://cran.at.r-project.org/")')
269269
rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
270270
if not os.path.isdir(rLibDir):
271271
os.mkdir(rLibDir)
272-
commands.append('.libPaths("%s")' % rLibDir )
272+
# .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!
273+
commands.append('deflibloc <- .libPaths()[1]')
274+
commands.append('.libPaths(c("%s",deflibloc))' % rLibDir )
273275
commands.append(
274276
'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="%s"))' % rLibDir)
275277
commands.append("library(\"rgdal\")");

‎python/plugins/sextante/r/scripts/Advanced_Raster_histogram.rsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
##[Example scripts]=group
33
##Layer = raster
44
##no_data_value = number 0
5+
##breaks = number 100
6+
##color = string red
57
##showplots
6-
Layer <- raster(Layer, 1)
78
NAvalue(Layer) = no_data_value
8-
hist(as.matrix(Layer), breaks=100, xlab = basename(filename(Layer)))
9+
hist(Layer, breaks=breaks,col=color)

0 commit comments

Comments
 (0)
Please sign in to comment.