Rutherford Platt
2015-Jan-08 16:07 UTC
[R] Trying to batch crop a folder of TIFFs -- "failure during raster IO"
Hi All,
I have a folder with approximately 300 large TIFFs, totaling about 30 gb. I am
trying to batch crop them by a shapefile (using functions from the raster and
rgdal packages). The script below works when I have a small number of TIFFs but
when I run it with 25 or so TIFFs I get the "Failure during raster IO"
error when I run crop. I'm assuming this is because of memory limitations.
Is there any way to crop and save each file individually without putting it all
in memory as a raster stack? Or do people have other suggestions? I'm a
fairly new user of R, so go easy on me. Thanks!
RVP
require(raster)
require(rgdal)
setwd("E:\\Trend Analysis\\LandsatStackFull")
boundary <- readOGR(getwd(), "study_unproj")
tiff.files <- list.files(getwd(),pattern="\\.tif$",
full.names=FALSE)
tiff.stack <- stack(tiff.files)
tiff.crop <- crop(tiff.stack, boundary)
[[alternative HTML version deleted]]