how can i solve Error problem while running stacking raster list?

107 views Asked by At

How can I solve this problem while running a stacking raster list? This is the program that I had run,

library(raster)
setwd("E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1.tar")
raslist <- paste0('E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B', 1:11, ".tif")
raslist
landsat8 <- stack(raslist)

It returns

library(raster)
setwd("E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1.tar") raslist <- paste0('E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B', 1:11, ".tif") 
 raslist [1] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B1.tif"
[2] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B2.tif" 
[3] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B3.tif" 
[4] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B4.tif" 
[5] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B5.tif" 
[6] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B6.tif" 
[7] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B7.tif" 
[8] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B8.tif" 
[9] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B9.tif" 
[10] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B10.tif" 
[11] "E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1_B11.tif"
 


landsat
8 <- stack(raslist)
Error in .local(.Object, ...) :  Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",  :    
    Cannot create a RasterLayer object from this file. (file does not exist)
1

There are 1 answers

0
Robert Hijmans On

You can see which file does not exist with

file.exists(raslist)

You may also try something like this

library(raster)
setwd("E:\\Gis-shp\\Chaurjahari\\LC08_L1TP_143040_20191016_20191029_01_T1.tar")
raslist <- list.files(pattern="LC08_L1TP_143040_20191016_20191029_01_T1_B.*tif$")
landsat8 <- stack(raslist)