  Am 27.10.2011 17:12, schrieb Swen Meyer:
> Dear All,
> I like to import a series of asci grids into R. It is a time series of
> 30 years and I like to calculate the mean monthly sum value for each
> grid node for every month of the year. This is way I´m doing this at the
> moment.
>
> #read asci files
> ####Month01
> EtRR.asci01<-  read.asciigrid("EVAPTR_dem30m_7101.sum", as.image=FALSE,
> plot.image=TRUE)
> EtRR.asci01@data$EVAPTR7101<- EtRR.asci01@data$EVAPTR_dem30m_7101.sum
> #1
> EVAPTR7201<- read.asciigrid("EVAPTR_dem30m_7201.sum", as.image=FALSE,
> plot.image=TRUE)
> EtRR.asci01@data$EVAPTR7201<- EVAPTR7201@data$EVAPTR_dem30m_7201.sum
> #2
> EVAPTR7301<- read.asciigrid("EVAPTR_dem30m_7301.sum", as.image=FALSE,
> plot.image=TRUE)
> EtRR.asci01@data$EVAPTR7301<- EVAPTR7301@data$EVAPTR_dem30m_7301.sum
> #3
> .
> .
> .
> #29
> EVAPTR0001<- read.asciigrid("EVAPTR_dem30m_0001.sum", as.image=FALSE,
> plot.image=TRUE)
> EtRR.asci01@data$EVAPTR0001<- EVAPTR0001@data$EVAPTR_dem30m_0001.sum
> #30
>
> # claculating the mean sum ofer 30 years
> EtRR.asci01@data$sum<- ((EtRR.asci01[[1]] + EtRR.asci01[[2]] +......+
> EtRR.asci01[[30]]) /30)
>
> My script is working well, but it is pretty time and workspace
> consuming. I tried to use wildcards like this:
>
> txt_files = list.files(pattern = 'EVAPTR_dem30m_*01.sum')
>
> But the result is then:
>
> character(0)
>
> Does anyone maybe have an idea how to import multiple asci-grids in a
> faster a more elegant way?
>
> Thank you in advance,
>
> Swen
>
>
> 	[[alternative HTML version deleted]]
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Dear Sven,

First: wildcards with * do not work. Just use pattern = 'EVAPTR_dem30m' 
to get all files in a folder within a list.
Second: use raster package and then function stack() to read all ascii 
grids without accessing memory.

So you can simply do a layer stack with your list within two r command 
lines and without memory handling problems ;-)

With Best regards

Carsten

-- 

Carsten Neumann
Telegrafenberg, A 17 01.13
14473 Potsdam
-------------------------------------------------------
Helmholtz Centre Potsdam
GFZ German Research Centre for Geosciences
Department 1 - Section 1.4 - Remote Sensing
-------------------------------------------------------
Tel.: +49 (0) 331 288 1766
e-mail: carstenn@gfz-potsdam.de


	[[alternative HTML version deleted]]

