I am trying to perform a raster stack using three spatial raster that are in .grd format, in R using the dismo package.The three grid files are in the path "D:~" . I am using this code,
files= list.files(path = "D:~",pattern = 'grd',full.names = TRUE)
the error output am getting is
Error in x[[1]] : subscript out of bounds
Can anyone help? thanks in advance
If the files are in sub-directories then you can use recursive=TRUE
:
files <- list.files(path="D:", pattern="grd", all.files=FALSE, full.names=TRUE,recursive=TRUE)
s <- stack(files)
Simply use the stack function from the raster package:
files=c("layer1.grd", "layer2.grd", "layer3.grd")
library(raster)
raster_stack=stack(files)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.