Points to line

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

Points to line

 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? Thanks Agus _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Open this post in threaded view
|
Report Content as Inappropriate

Re: Points to line

 On Tue, Jul 17, 2012 at 2:34 PM, Agustin Lobo <[hidden email]> 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.htmlBarry _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo