I'd like to extract celle numbers from a raster using a line, but it seems
the cellnumbers=TRUE option isn't working with lines in raster::extract.

simple example :
library(raster)
r <- raster(matrix(1:20, nrow=4))
l <- SpatialLines(list(Lines(list(Line(list(x=c(0, 1), y=c(0, 1)))), ID=1)))
# that's really straightforward !
# visualize
plot(r, asp=1); lines(l)
extract(r, l)
# [[1]]
# [1] 13 17 10 14  7 11  4  8

extract(r, l, cellnumbers=TRUE)
# [[1]]
# [1] 13 17 10 14  7 11  4  8

As you can see, it brings the same results. I'm also not sure I get the
order in which the values are returned, but it seems it is not from the
begining of the line to the end or reverse.

I don't know, maybe I could use rasterize to bring the cell numbers instead,
but I can't figure how ?

Any help would be appreciated,
Etienne

	[[alternative HTML version deleted]]

