[R-sig-Geo] Rasters average
Robert Hijmans
r.hijmans at gmail.com
Wed Feb 9 17:08:38 CET 2011
>I'm trying to use MODIS 1day raster (.tif file) to obtain a, say, weekly
>raster which is the average of the seven 1 day raster.
>Using the following code (library raster) I can't obtain the results due to
>computational limits.
Luca,
You can do something like:
s <- stack(paste("C:/MOD11A2/Confronto/1d00", 1:7, ".tif", sep=""))
fun <- function(x, ...) { x[x==0] <- NA; mean(x, na.rm=TRUE) }
m <- calc(s, fun)
I am not sure what you mean by "computational limits"; are you saying that
this takes a long time? If so, that would be because you are looping over
cells. Avoid that, and things will be faster.
Robert
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Rasters-average-tp6007034p6008219.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list