I have hundreds of rasters with same resolution and extent. It's a time series and each raster represent one point of time.
I know how to find the absolute maximum value in a raster.
But how can I find the maximum value in each cell in the entire time series of rasters?
If a1,a2,......a1000 are rasters, I want to create a raster x where each pixel is the maximum of all corresponding pixels of a1-a1000.
If you first put the rasters in a stack, you can then simply apply min() or max() to the stack to get the summary RasterLayer you're after
## Example rasters and stack
r1 <- raster(matrix(1:4,ncol=4))
r2 <- -2*r1
r3 <- 2*r1
rr <- list(r1,r2,r3)
s <- stack(rr)
## Extract the pixel-wise min and max values
min(s)
max(s)
(To apply some other, more complicated function that returns a scalar for each pixel in the stack, you may want to use calc(), as demonstrated (for example) here.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With