Search code examples
rarcgis

How to convert times series raster stack to matrix or large list in r?


I have a raster stack with 84 bands belonging to a time frame. I would like to convert the raster stack to a matrix or a large list with lat long as variables, date field and field with the data for the location for that date.


Solution

  • You can do something like this:

    s <- stack(system.file("external/rlogo.grd", package="raster"))
    x <- as.data.frame(s, xy=TRUE)
    y <- reshape(x, direction='long', varying=3:ncol(x), v.names='value', timevar='time')