terra
terra copied to clipboard
Mosaic fails since 1.7.39 (at least)
The following MRE is working with 1.7.29 but returns incorrect output with 1.7.39
library(terra)
x1 <- rast(xmin=-110, xmax=-60, ymin=40, ymax=70, res=1, vals=1)
x2 <- rast(xmin=-110, xmax=-60, ymin=40, ymax=70, res=1, vals=2)
x <- c(x1, x2)
y1 <- rast(xmin=-95, xmax=-45, ymax=60, ymin=30, res=1, vals=3)
y2 <- rast(xmin=-95, xmax=-45, ymax=60, ymin=30, res=1, vals=4)
y <- c(y1, y2)
m1 <- mosaic(x, y)
m1
1.7.29
class : SpatRaster
dimensions : 40, 65, 2 (nrow, ncol, nlyr)
resolution : 1, 1 (x, y)
extent : -110, -45, 30, 70 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84
source(s) : memory
names : lyr.1, lyr.1
min values : 1, 2
max values : 3, 4
1.7.39
class : SpatRaster
dimensions : 40, 65, 2 (nrow, ncol, nlyr)
resolution : 1, 1 (x, y)
extent : -110, -45, 30, 70 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84
source(s) : memory
names : lyr.1, lyr.1
min values : 1.5, 1.5
max values : 3.5, 3.5
Thanks very much for reporting this ugly bug. Fixed now, but I am not closing this issue yet as I want to look at this a bit more.