Parallel overlay of undefined multi-layer rasters

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Parallel overlay of undefined multi-layer rasters

Hugo Costa
Dear list

I have an undefined number of multi-layer rasters (TIFF files with 10
bands), and I need to find the maximum (or median, etc.) among the rasters.
The calculations should operate band by band, so the expected output is one
stack also with 10 bands.

I thought of overlay, like this:

r <- raster(ncol=10, nrow=10)
r1 <- init(r, fun=runif)
r2 <- init(r, fun=runif)
r3 <- init(r, fun=runif)
r4 <- init(r, fun=runif)
f<-function(...){max(...,na.rm = TRUE)}

# works for undefined stacks, but not in parallel
list2<-list(s1,s2,s3,fun=f), list1), list2)

As for parallel processing, I thought of clusteR, but it accepts only one
Raster* object.
The problem is that for running overlay with multi-layer rasters, they
cannot be stacked, because if stacked, the function will apply to all bands
and hence output a single band, while in this case the function should
apply band by band.

An alternative to this, is to split the bands of all images, process the
bands individually in parallel inside a loop (i.e. band 1 of all images,
band 2 of all images, etc.),
and then combine the outputs in a multi-layer raster. However, this is
inefficient, specially with large rasters not hold in memory.

Is there an elegant way to do this?


        [[alternative HTML version deleted]]

R-sig-Geo mailing list
[hidden email]