R 3.0.0 and spatial classes
On Sun, Dec 16, 2012 at 6:53 PM, Chris English <sglish at hotmail.com> wrote:
Edzer: On Tue, Jul 17, 2012 at 2:34 PM, Agustin Lobo ~ from Barry Rowlingson wrote: 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)
Convoluted is not the same as orphaned, certainly, but one gets the sense that 'Line' owes its existence to matters of plotting rather than line as line, independent of drawing it, and this may have some import upon line analysis and the possibility of arriving at topology and dispensing with shared lines and the like.
"Line" is a non-spatial Line, made up from an ordered set of (x,y) coordinate pairs. It cannot have a coordinate system assigned to it. "Lines" is a list of Lines, making a non-spatial set of Line segments. It too cannot have a coordinate system assigned. "SpatialLines" is a spatial set of Lines, for when you have a number of features each of which may be composed of several disconnected segments. It can have a coordinate system assigned. You are making a SpatialLines object where a single feature has a single line segment. The slightly annoying list(Lines(list(Line(...)))) dance is unavoidable because the lists are necessary since the lists can have more than one element, but you could easy create a 'SimpleSpatialLine' function that did all that. It might even make sp for R 3.0.0! (SimpleSpatialPolygon might be handy too...) Another possibility might be to write methods for SpatialLines that takes a matrix and skips the complexity for simple cases... Barry