[R] Trying to batch crop a folder of TIFFs -- "failure during raster IO"

Rutherford Platt rplatt at gettysburg.edu
Thu Jan 8 17:07:00 CET 2015

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!

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]]

More information about the R-help mailing list