I'm getting a weird error when trying to read a raster into R.
>r <- raster('myraster.tif') Error in .local(.Object, ...) : TIFFReadDirectory:Failed to read directory at offset 2606110 Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file.
It is definitely reading from the correct location, as when I try to read in something that does not exist, I get a completely different error:
> r <- raster('thisrasterdoesnotexist.tif') Error in .local(.Object, ...) : `C:\Users\Documents\thisrasterdoesnotexist.tif' does not exist in the file system, and is not recognised as a supported dataset name. Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. (file does not exist)
I was reading and writing rasters from this directory just a few minutes ago. I've tried restarting R and my computer without success.
So the rasters that are doing this are ones that I recently downloaded using the function download.file(). Other rasters are reading in fine. When I used download.file() I did it with just arguments url and output filename. Am I missing something about how do download tiffs from the internet?
Also, my session info:
> sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit) locale:  LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252  LC_MONETARY=English_United States.1252 LC_NUMERIC=C  LC_TIME=English_United States.1252 attached base packages:  stats graphics grDevices utils datasets methods base other attached packages:  rgdal_0.9-1 raster_2.3-24 sp_1.1-0 loaded via a namespace (and not attached):  grid_3.1.1 lattice_0.20-29 ncdf_1.6.8 tools_3.1.1