[R-sig-Geo] Points to line
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Tue Jul 17 15:49:44 CEST 2012
On Tue, Jul 17, 2012 at 2:34 PM, Agustin Lobo <alobolistas at gmail.com> wrote:
> Hi!
>
> Is there a function to convert a set of ordered points (i.e. in a
> Spatial Points Data Frame)
> into an Spatial Line object?
No, because there's no such thing as a Spatial Line object, or even a
SpatialLine object :)
There are Line objects, Lines objects, SpatialLines objects and
SpatialLinesDataFrame objects, all with different structures and
meanings.
To convert to SpatialLines, get the coordinates and build in the
usual convoluted manner:
> s=data.frame(x=runif(10),y=1:10,z=rnorm(10))
> coordinates(s)=~x+y
> L = SpatialLines(list(Lines(list(Line(coordinates(s))),"X")))
> plot(L)
My spatial cheatsheat might help:
http://www.maths.lancs.ac.uk/~rowlings/Teaching/UseR2012/cheatsheet.html
Barry
More information about the R-sig-Geo
mailing list