SpatialLines from SpatialLinesDataFrame
On Mon, 9 Jul 2012, Lyolya wrote:
Dear List,
I am trying to create a map for a SpatialPointsDataFrame object (package
sp), and I want to use some lines as a layout for my plot. I use the
function spplot and its argument sp.layout for the purpose. The point is, I
cannot figure out how to retrieve a SpatialLines object from a
SpatialLinesDataFrame that I got. I.e, I try to do the following:
#points_object - a SpatialPointsDataFrame
#lines_object - a SpatialLines object
#lines_data_frame - a SpatialLinesDataFrame
spplot(points_object, cuts, sp.layout=list("sp.lines", lines_object), main)
and the problem is that I don't know how to derive the lines_object from
the lines_data_frame. I have already tried the options:
lines_object <- as.SpatialLines.SLDF(lines_data_frame)
Where did you get that from? These are all S4 classes, so the coercion method is: as(lines_data_frame, "SpatialLines") However, you probably do not need to do anything, as the sp.layout "sp.lines" function takes objects which can be coerced to SpatialLines, including SpatialLinesDataFrame. Roger
and
p.layout=list("sp.lines", lines_data_frame at lines)
but none of these works for the plot.
Could you please indicate me how I could make it work?
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no