1

I'm trying to use the mosaic function (package: raster) in R to join two geo-tiff rasters together. Both are derived from LandSat tiles. I understand that mosaic requires

All objects must have the same origin, resolution, and coordinate reference system.

Unfortunately, the two tiles have different CRS

+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0

and

+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 

leading to

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

So, I converted them to the same crs by using projectRaster - I've tried reprojecting both rasters to both epsg:3857 and epsg:4326

However, having done this, in both cases when I run the mosaic function I get the error

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

How can I fix this? Is there a different crs I could use that would use the same origin for both?

1

So my workaround was to create a very large raster file (just drew it out in QGIS) that covers the entirety of the desired area, then resample using that raster for the parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.