Hi I have two questions concerning the function calc() (more accurately .calcLayers()) (I append the code of the function below) :
1) The value given to the function fun() is a matrix, containig the values for many calls from all layers - this is not clear from the help page, and probably should be changed as it complicates the development of fun() functions. It effectively assumes, that the function fun() does vectorize the input parameter, which is in most cases when more complicated calculations are done, not the case (at least not for me). I would suggest to put it up to discussion, if this behaviour should be changed. 2) Is the (!canProcessInMemory(x, 2)) correct? I would actually assume, that the processing in one piece is only done, when canProcessInMemory() is TRUE? Cheers and thanks a lot for this really hice package (I am back and using it again), Rainer .calcLayers <- function(x, fun, filename='', ...) { filename <- trim(filename) outraster <- brick(x, values=FALSE) if (!canProcessInMemory(x, 2)) { v <- t( fun( t( getValues(x) )) ) if (filename != '') { outraster <- writeRaster(outraster) } return( setValues(outraster, v) ) } if ( filename == '') { filename <- rasterTmpFile() } outraster <- writeStart(outraster, filename=filename, ...) tr <- blockSize(outraster) pb <- pbCreate(tr$n, type=.progress(...)) for (i in 1:tr$n) { sv <- t( fun( t( getValues(x, row=tr$row[i], nrows=tr$nrows[i]) )) ) outraster <- writeValues(outraster, sv, tr$row[i]) pbStep(pb) } outraster <- writeStop(outraster) pbClose(pb) return(outraster) } -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax: +27 - (0)86 516 2782 Fax: +49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo