Calculate trend in large raster stack in R

admin

Administrator
Staff member
I want to calculate the trend of a raster stack in R, using daily data for 50 years for the whole of Europe.

Code:
time <- 1:nlayers(gimms.sum) 
fun=function(x) { if (is.na(x[1])){ NA } else { m = lm(x ~ time); summary(m)$coefficients[2] }}
gimms.slope=calc(gimms.sum, fun)

The code above was taken from here [1]. However, I get the message that the vector is 8.6 Gb and cannot allocate the memory

[1] <a href="https://matinbrandt.wordpress.com/2...-series-trend-anaylsis-with-ndvi-gimms-and-r/" rel="nofollow noreferrer">https://matinbrandt.wordpress.com/2...-series-trend-anaylsis-with-ndvi-gimms-and-r/</a>

How could I deal with this issue?