Thanks Jonathan, I will give a try.
:) On Tue, Feb 18, 2014 at 2:55 PM, Jonathan Greenberg <j...@illinois.edu>wrote: > Eddie: > > This is the Windows x64 version of R 3.0.2, right? I found that the > x64 release for whatever reason R needs to be launched with the > --max-mem-size=XXXM flag if you want more than 2gb available to R. > > XXX is the number of megabytes to give it access to. This seemed to > have been a change from 3.0.1 (which seemed to set the memory to be > the max available on the system). Give this a shot when you launch > it. Check > http://stackoverflow.com/questions/1395229/increasing-the-memory-available-to-r-processes > for some hints on this (you can append the setting to your GUI > shortcut). > > You should also follow Robert's suggestion and set the chunkSize to be > VERY small if the max-mem-size doesn't work. > > --j > > > > On Tue, Feb 18, 2014 at 7:08 AM, Eddie Smith <eddie...@gmail.com> wrote: > > Thank you very much Robert. > > > > Tried to increase to set the chunksize as suggested( > > rasterOptions(chunksize=1e+05)) but still no luck. > > > > The full session is: > > > >> sessionInfo() > > R version 3.0.2 (2013-09-25) > > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > > [1] LC_COLLATE=English_United Kingdom.1252 > > [2] LC_CTYPE=English_United Kingdom.1252 > > [3] LC_MONETARY=English_United Kingdom.1252 > > [4] LC_NUMERIC=C > > [5] LC_TIME=English_United Kingdom.1252 > > attached base packages: > > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > > [1] rgdal_0.8-16 raster_2.2-12 sp_1.0-14 > > loaded via a namespace (and not attached): > > [1] grid_3.0.2 lattice_0.20-24 > > My rasterstack is huge but I haven't got any problem with this > rasterstack > > before. > > > >> flag7 > > class : RasterStack > > dimensions : 1032, 1656, 1708992, 10592 (nrow, ncol, ncell, nlayers) > > > > Thanks. > > > > > > > > On Tue, Feb 18, 2014 at 2:59 AM, Robert J. Hijmans <r.hijm...@gmail.com > >wrote: > > > >> Eddie, > >> The function does not work (maxsst is not defined). You are not > >> providing sessionInfo() > >> You should be able to avoid memory problems (if that is what causes > >> this) via rasterOptions(chunksize=___) > >> > >> E.g., > >> > >> rasterOptions(chunksize=1e+05) > >> > >> Robert > >> > >> > >> On Mon, Feb 17, 2014 at 11:19 AM, Eddie Smith <eddie...@gmail.com> > wrote: > >> > Hi guys, > >> > > >> > Everytime I tried to run calc(), R crashed. Any advice? > >> > Here is my code: > >> > > >> > #clear memory/remove all R objects > >> > rm(list=ls()) > >> > > >> > #check memory size and set memory limit > >> > memory.size() > >> > memory.limit(10000) > >> > > >> > #Load related packages library > >> > library(raster) > >> > library(rgdal) > >> > > >> > #Load all raster data in a folder > >> > img <- list.files(pattern='\\.img$') > >> > > >> > #Check rasters > >> > list(img) > >> > > >> > #Stack layers into one file > >> > flag7 <- stack(img) > >> > > >> > #2 CReate fun > >> > time <- 1:nlayers(flag7) > >> > fun <- function(x) { > >> > if (all(is.na(x))) { > >> > return(cbind(NA,NA,NA)) > >> > } > >> > xcost<-cos(2*pi*time/366) > >> > xsine<-sin(2*pi*time/366) > >> > m = lm(x~xcost+xsine) > >> > s <- summary(m) > >> > maxval <- max(predict(m)) > >> > r2 <- s$r.squared > >> > sigma <- s$sigma > >> > cbind(maxsst, r2, sigma) > >> > } > >> > > >> > #3 Run function with rasterstack > >> > r <- calc(flag7, fun) > >> > > >> > [[alternative HTML version deleted]] > >> > > >> > _______________________________________________ > >> > R-sig-Geo mailing list > >> > R-sig-Geo@r-project.org > >> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > >> > > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > > R-sig-Geo mailing list > > R-sig-Geo@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > > > -- > Jonathan A. Greenberg, PhD > Assistant Professor > Global Environmental Analysis and Remote Sensing (GEARS) Laboratory > Department of Geography and Geographic Information Science > University of Illinois at Urbana-Champaign > 259 Computing Applications Building, MC-150 > 605 East Springfield Avenue > Champaign, IL 61820-6371 > Phone: 217-300-1924 > http://www.geog.illinois.edu/~jgrn/ > AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007 > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo