I imported raster files into R
(Landsat TM-5 surface reflectance products). Now I want to crop these rasters using boundaries of my test region (also raster file).
Importing went well without any mistakes. But when I tried to use crop function I've got an error message: Error in .local(.Object, ...)
:
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. (file does not exist).
I cannot figure out what the problem is. I have tried, but the code run unsuccessfully. The code and the error are these:
red0610=raster("LT51710242010172MOR00_sr_band3.tif")
nir0610=raster("LT51710242010172MOR00_sr_band4.tif")
red0910=raster("LT51720242010259MOR00_sr_band3.tif")
nir0910=raster("LT51720242010259MOR00_sr_band4.tif")
testfields=raster("testfields.tif")
red0610=crop(testfields,red0610)
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file. (file does not exist)
Imported files located in working directory. I would be very greatful for any help.