I am trying to mosaic Landsat MSS scenes using the mosaic function in the R package raster. To explain the problem, I have considered here the four following TIF files, which I want to mosaic:

  1. LM03_L1TP_147044_19800220_20200906_02_T2_B4.TIF
  2. LM03_L1TP_147045_19800202_20200905_02_T2_B4.TIF
  3. LM03_L1TP_148044_19800221_20200905_02_T2_B4.TIF
  4. LM03_L1TP_148045_19800221_20200905_02_T2_B4.TIF

All the files are downloaded from the Earthexplorer portal of USGS. From the names of the above files, it can be seen that the tiles are situated next to each other, as their WRS paths and rows are 147, 148 and 44, 45, respectively. Also, the dates the images are taken are close to each other. I have tried to mosaic the scenes using the following R code:


r1 = raster("LM03_L1TP_147044_19800220_20200906_02_T2_B4.TIF")
r2 = raster("LM03_L1TP_147045_19800202_20200905_02_T2_B4.TIF")
r3 = raster("LM03_L1TP_148044_19800221_20200905_02_T2_B4.TIF")
r4 = raster("LM03_L1TP_148045_19800221_20200905_02_T2_B4.TIF")

r5 = mosaic(r1, r2, r3, r4, fun = mean)

However, I get the error:

Error in compareRaster(x, extent = FALSE, rowcol = FALSE, orig = TRUE,  : 
  different CRS

Indeed, when I inquired using the function crs, I got the following:

> crs(r1)
CRS arguments:
 +proj=utm +zone=46 +datum=WGS84 +units=m +no_defs 
> crs(r2)
CRS arguments:
 +proj=utm +zone=46 +datum=WGS84 +units=m +no_defs 
> crs(r3)
CRS arguments:
 +proj=utm +zone=45 +datum=WGS84 +units=m +no_defs 
> crs(r4)
CRS arguments:
 +proj=utm +zone=45 +datum=WGS84 +units=m +no_defs

Here I found the zone argument different for the scenes. I wonder what mistake I have made, and how to properly mosaic the scenes using the raster package in R.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.