# NOT RUN {
r <- rast(ncols=10, nrows=10)
values(r) <- 1:ncell(r)
r[c(1:25, 31:100)] <- NA
r <- ifel(r > 28, r + 10, r)
# get all non-NA cell numbers
cells(r)
# get cell numbers that match values
cells(r, c(28,38))
m <- cbind(x=c(0,10,-30), y=c(40,-10,20))
cellFromXY(r, m)
v <- vect(m)
cells(r, v)
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
r <- rast(v)
#cv <- cells(r, v)
#z <- cells(r,ext(v))
#xy <- xyFromCell(r, z)
#plot(v)
#points(xy)
# }
Run the code above in your browser using DataLab