dhyeyey
dhyeyey

Reputation: 15

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.

Upvotes: 1

Views: 735

Answers (1)

Robert Hijmans
Robert Hijmans

Reputation: 47401

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')

Upvotes: 1

Related Questions