how to combine raster layers from a stack into a data frame R
I have a stack made of rasters
s<-stack(list of ASCI files)
I am trying to perform this operation
df<-as.data.frame(c(s[[1]],s[[2]],s[[2]],s[["bathymetry"]]))
but I get this error Error in as.data.frame.default(x[[i]], optional =
TRUE) : cannot coerce class "structure("RasterLayer", package = "raster")"
to a data.frame
When I perform this operation on a single raster such as
df<-as.data.frame(s[[1]])
everything works fine. But I have to extract many rasters and combined
them in one dataframe. The only solution I see now is to extract them
individually and then combined them, is there a better solution? I am
working with hundreds of raster at a time.
No comments:
Post a Comment