library(raster)
img <- list.files(pattern='*.img')
stack <- stack(img)
The code above should work but despite having *.img files in my folder, I also have *img.xml and *img.aux.xml files. How do I rewrite my code so that it only stack *.img files?
This will only match files that end with img
.
library(raster)
img <- list.files(pattern='\\.img$')
stack <- stack(img)
Note the $
at the end, this signifies ends with
.