>
> I did notice that, but there was no ==line== section in the doc I have. Is
> my package outdated ?
> >
>
> No, there were no additional arguments for lines specifically. There is one
> now (cellnumbers) in the R-Forge version (1.8-6).
>
> Thanks Robert for that new addition.

>
> >> The values are first in row order, and then in column order.  Not in the
> >> order of the coordinates of the line(s).
> >>
>
> >I'm trying to think of a way to order these. Do you see a simple solution
> ?
> >I'm finally doing a profile from a raster using a line.
>
> Below I show how -- I think -- you can order the values such that they
> follow the line.
>
>
> 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)))
> plot(r, asp=1); lines(l)
>
> a <- extract(r, l, cellnumbers=T)[[1]]
> rc <- rowColFromCell(r, a[,1])
> b <- cbind(rc, value=a[,2])
>
> #order top to bottom
> b[order(-b[,1], b[,2]), 3]
> #order bottom to top
> b[order(b[,1], -b[,2]), 3]
> # or
> rev( b[order(-b[,1], b[,2]), 3] )
>
> This is working, many thanks. However, I plan to use it on more complex
lines where that solution (ordering from coordinates) won't be effective. I
believe I should look for a line or points type as output instead of a
raster/pixel type, so I could not only order the results in terms of
distance along a line, but also know the length of the intersection.
In ArcGis, there is that dimension they call m which allow to order objects
or events on a line. Is there something similar in R ? I've seen some
discussions about overlaying a line on a raster but it doesn’t seem to yield
a line with values along it.

Etienne

	[[alternative HTML version deleted]]

