Your example or description is not perfectly clear to me so I may be off,
but wouldn't you be better off by reading your files into a RasterBrick or
RasterStack, summing through the layers and multiplying by a ratio?

Cheers,
Roman



On Wed, Oct 10, 2012 at 4:29 PM, Milena <milenafb@gmail.com> wrote:

> Hello!
> I hope someone can help me! I have radar images, they're matrixes 240x240
> in TXT format. The information is about rain, in mm/h. I need to transform
> them to total rain (only mm), so I have to multiply the matrixes to 5/60
> (temporal resolution is 5 minutes).
> Well, I have a script that theorically can make this ratio. It makes a
> looping too because I have too many images. But, it's not working...
> Any ideia about what is going wrong? Or another way to make this
> multiplication?
> Thanks!!!!
> Milena Fogliarini Brolesi
> (Unicamp)
>
> #create the raster based in another raster image (cappi_dimension)and set
> value = 0 to make the sum possible
>
> cappi_example<-raster(readAsciiGrid("C:/Users/MFB/Documents/Mestrado/cappi_teste/V1_CAPPIH030R2_20030101_1534.txt",
> as.image = FALSE, proj4string = CRS("+proj=longlat +datum=WGS84")))
> cappi_example[is.na(cappi_example)]<-0
> cappi_raster_sum<-setValues(raster(cappi_example, filename =
> "cappi_raster_sum", values = NULL), values = 0)
>
> #for loop to read all images in a folder, sum all images and aply a ratio
> to transform mm/h in mm
> ratio<-5/60
>
> for (ii in 1: length(file_list)) {
>
> file_path<-paste(folder_path, file_list [ii],sep = "")
> library(raster)
> cappi<-raster(readAsciiGrid(file_path, as.image = FALSE, proj4string =
> CRS("+proj=longlat +datum=WGS84")))
> cappi[is.na(cappi)]<-0
> cappi_raster_sum<-sum(cappi_raster_sum,cappi)*ratio
> }
> summary(cappi_raster_sum)
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]

