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

Reply via email to