I try to build a SpatRast with 2 layers, using the "xyz" reading style. It works with 3 columns as input to the rast function, but I get a warning message with 4 columns:
> rast(as.matrix(data.frame(x=c(1,1,2,2),y=c(1,2,1,2),z1=1:4)),type="xyz")
class : SpatRaster
dimensions : 2, 2, 1 (nrow, ncol, nlyr)
resolution : 1, 1 (x, y)
extent : 0.5, 2.5, 0.5, 2.5 (xmin, xmax, ymin, ymax)
coord. ref. :
data source : memory
names : z1
min values : 1
max values : 4
> r=rast(as.matrix(data.frame(x=c(1,1,2,2),y=c(1,2,1,2),z1=1:4,z2=5:8)),type="xyz")
Warning message:
In v[cells] <- xyz[, 3:d[2]] :
number of items to replace is not a multiple of replacement length
Any idea why?