So, I have two different rasters
, and I am trying to match their extent, even though the difference in their existing extents is quite small, but still raster::stack
won't stack which is understandable. But, when I use the crop
function to crop one raster on the basis of the other raster's extent, their extents still don't match up i.e., xmax
of rast1
doesn't change from 757322.8
to 757322.7
. . How can I solve this problem, when the purpose of stacking them together to compute standard deviation? I also tried using the raster::extend
function but that is giving me a memory error.
library(raster)
rast1 = raster::brick("path/rast1.tif")
rast2 = raster::brick("path/rast2.tif")
# Get the extent
extent(rast1)
class : Extent
xmin : 756472.2
xmax : 757322.8
ymin : 4074670
ymax : 4074953
extent(rast2)
class : Extent
xmin : 756472.2
xmax : 757322.7
ymin : 4074670
ymax : 4074953
extent_1 = c(756472.2 ,4074670 ,757322.7 ,4074953)
rast1_Crop = crop(rast1, extent_1)
stack = raster::stack(rast1_Crop , rast_2)
Error
Error in compareRaster(x) : different extent
-te
and-tr
parameters. Warping leads to resampling and it may alter the pixel values but with your data that should not happen with nearest neighbor resampling because pixels will be only slightly shifted.