Hi,
I am moving from raster to terra. I get an error when I adapt the following raster code:
require(raster)
set.seed(666)
reps=10
r <- raster( matrix(nrow=reps,ncol=reps, round(rnorm(reps^2),1)))
extent(r)<- c(1,101,1,101)
plot(r)
xy<-xyFromCell(r,r[r>0])
z<-r[r>0]
cbind(xy,z)
Under terra code:
require(terra)
r <- rast( matrix(nrow=reps,ncol=reps, round(rnorm(reps^2),1)))
plot(r)
xy<-xyFromCell(r,r[r>0])
Error in r[r > 0] : object of type 'S4' is not subsettable
What am I doing wrong?
Thanks
herry
in terra