I have a large number of rasters in grid format ("asc"). I created a list of files:
files <- list.files("D:/......../EnvironData", pattern='asc',
full.names = TRUE)
Then I want to stack all files:
dataStack <- raster::stack(files)
Unfortunately, I get the following error:
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file.
All raster files have the same spatial dimension and extent.
1 Answer 1
This problem happened to me too, but it was because my directory was large. R was unable to find the way, so he gave this answer: Error in .rasterObjectFromFile (x, band = band, objecttype = "RasterLayer",: Cannot create a RasterLayer object from this file. (File does not exist)
After I put it in another folder with a smaller path, it worked.
lapply
call suggested by mdsummer into your question?