Skip to content
Prev 22365 / 29559 Next

Creating a data frame from a set of rasters that includes XY values as columns

Something like this should do the trick, depending on the size of the
raster stack and the computing environment of course:

library(raster)

fn <- system.file("external/test.grd", package="raster")
s <- stack(fn, fn)
r <- raster(fn)
s <- stack(r, fn)

dfs <- as.data.frame(s, xy=TRUE)


checkout ?raster:::as.data.frame for more options

-Andrew

On Tue, Feb 24, 2015 at 9:19 AM, Damian Maddalena <damianmaddalena at gmail.com