Open JKupzig opened 6 months ago
?mosaic
The SpatRasters must have the same origin and spatial resolution.
origin(x1)
[1] 433 -113
origin(x2)
[1] 201 -94
origin(x3)
[1] 500 296
origin(x4)
[1] 86 139
origin(x5)
[1] 229 500
origin(x6)
[1] 358 482
origin(x1) <- c(0,0)
origin(x2) <- c(0,0)
origin(x3) <- c(0,0)
origin(x4) <- c(0,0)
origin(x5) <- c(0,0)
origin(x6) <- c(0,0)
x_lst = list(x1, x2, x3, x4, x5, x6)
collect_orig <- sprc(x_lst)
m1 = mosaic(collect_orig)
plot(m1)
Should resolve with additional data prep.
Hi, thanks for the suggestions. Sorry, for the late reply. I've just checked with my original data and unfortunately, my original rasters do have the same origin...
For now, I've found a workaround to get one raster out of my six by having all of my rasters in the same extent and resolution (and all cells outside the original rasters are filled with NA), so I can use simple raster calculation.
I am trying to merge rasters with same crs and resolution but different extent to one bigger raster. For overlapping areas the function mean should be applied. When I apply mosaic to all my rasters the result is broken. (s. picture below). When I am using merge instead, it works.
Further I have encountered, that using a subset of rasters or doing the mosaic-merge in two steps works. Also, when I apply a different function than mean (e.g, first) it works as expected. Here is a minimal reproducable example
I am working on Ubuntu Yammy and this is my SessionInfo