Thanks Robert,

I started out using the function 'calc' with "lowess", the same way as you
indicate. But then I think, perhaps it is more efficient to do it in chunks
(for large raster data). Thats its my question now, with calc? or in chunks?

However, I did what you told me and seems like in chunks take more time
that with 'calc'. Can this happen?

Francisco



2013/5/8 Robert J. Hijmans <r.hijmans@gmail.com>

> Francisco,
>
> I think what you want to do can be accomplished with 'calc' (as was
> pointed out in another thread).
>
> library(raster)
> in <- stack(list.files(pattern=*..tif$))
> out <- calc(in, fun=function(x) lowess(x,f=7/n,iter=10)$y)
>
>
> But to answer your question, I think you could do:
>
> in <- stack(list.files(pattern=*..tif$))
> # and, here is the trick
> out <- brick(in, values=FALSE)
>
> Also, in your loop you could do:
>
> getValues(in, ...
> writeValues(out, ....
>
>
> Best, Robert
>
> On Tue, May 7, 2013 at 7:35 AM, Francisco Zambrano <frzambra@gmail.com>
> wrote:
> > Hi everybody,
> >
> > I'm working with MODIS data MOD13Q1 and the NDVI index between 2000-
> today.
> > I have been trying to do a function, but I have a problem when stack the
> > 310 files and then I tried to use the writeStart function. I had an error
> > because the startFuction work with rasterLayer or RasterBrick. But, when
> I
> > tried to make the brick with the rasterStack (>brick(rasterStack)) the
> > operation took too much time (11 hours)
> >
> > My question, is what is the most efficiently way to make a rasterBrick
> from
> > multiple raster (geoTIFF) files?
> >
> > save the rasterStack and then open it with brick?
> >
> > My code is something like:
> >
> >>out<-stack(list.files(pattern=*..tif$))
> >>out<-brick(mod) #too much time (11 hours appox)
> >
> >   >out<-writeStart(out,filename,overwrite=TRUE)
> >   >bs<-blockSize(out)
> >   >pb<-pbCreate(bs$n)
> >   >for (i in 1:bs$n){
> >     v<-getValues(out,row=bs$row[i],nrows=bs$nrows[i])
> >     s<-t(sapply(apply(v,1,lowess,f=7/n,iter=10),"[[","y"))
> >     out<-writeValues(out,s,bs$row[i])
> >    pbStep(pb,i)
> >   }
> >
> > Kind Regards
> >
> > Francisco Zambrano Bigiarini
> >
> > from Chile, latin america
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
“El que te roba una idea se queda con un pedazo de tí, pero pierde dos
pedazos de sí: la imaginación y el honor”

	[[alternative HTML version deleted]]

