Reputation: 681
I am trying to import about 50 .tif files into a stack using the rasters package. Because of the large number of files I don't want to list them all out. I have tried a few methods but have been unsuccessful, including this code:
test<-stack(choose.files(),values=T) Error in .local(x, ...) : Arguments should be Raster* objects or filenames
In addition I want to classify a new raster based on the 50 I import. For example I have a group of polygons with the same extent (could convert to raster) and want to count the number of times a value "1" occurs in each polygon. I figure the "overlay" function would be best for this but am having trouble thinking of how to code the associated function. Any help would be appreciated.
Upvotes: 0
Views: 1127
Reputation: 47051
The easier way with many files should be to use (with some modifications)
f <- list.files(path='???', pattern='.tif$', full.names=TRUE)
s <- stack(f)
But if you want to do it interactively:
f <- choose.files()
s <- stack(f)
The error occurred because you use "values=TRUE" (which is not an argument to stack and gets interpreted as a file name)
Upvotes: 1