Skip to content
Prev 10256 / 29559 Next

gridded time series analysis

Dear Advait,
Apparently the values in these cells are all the same (not that you
only use the first 8 time steps, not all 120)

Here is an example with random values in which the slopes are all different

b <- brick(ncol=4, nrow=4, nl=120)
b <- setValues(b, matrix(runif(prod(dim(b))), ncol=120))
fun = function(x) { if(is.na(x[1])) { NA } else { lm(x[1:60] ~
x[61:120])$coefficients[2] } }
x <- calc(b, fun)
plot(x)
as.matrix(x)
No
Yes. rows are cells (4*4=16), columns are layers.
See an example above, assuming that if the first time step is NA, they
all are. You could also do things like
if (sum(is.na(x)) > 60)
depends on your context.


Best, Robert
On Mon, Dec 6, 2010 at 8:30 AM, Advait Godbole <advaitgodbole at gmail.com> wrote: