Coercion between sp objects and spatstat psp objects
Functions to convert between spatstats planar segment pattern (psp
)
format and various sp line formats. S4-style as()
coercion can be
used as well.
as.psp.Line(from, ..., window=NULL, marks=NULL, fatal) as.psp.Lines(from, ..., window=NULL, marks=NULL, fatal) as.psp.SpatialLines(from, ..., window=NULL, marks=NULL, characterMarks = FALSE, fatal) as.psp.SpatialLinesDataFrame(from, ..., window=NULL, marks=NULL, fatal) as.SpatialLines.psp(from)
from |
object to coerce from |
... |
ignored |
window |
window of class |
marks |
marks as defined in the spatstat package |
characterMarks |
default FALSE, if TRUE, do not convert NULL marks to factor from character |
fatal |
formal coercion argument; ignored |
signature(from = "Line", to = "psp")
signature(from = "Lines", to = "psp")
signature(from = "SpatialLines", to = "psp")
signature(from = "SpatialLinesDataFrame", to = "psp")
signature(from = "psp", to = "SpatialLines")
In spatstat all spatial objects are assumed to be planar. This means
that spatstat is not designed to work directly with geographic
(longitude and latitude) coordinates. If a sp object is declared to
have geographic (unprojected) coordinates maptools refuses to convert
directly to spatstat format. Rather, these should be projected first
using e.g. spTransform
. If you know what you are doing, and
really want to force coercion, you can overwrite the proj4string
of the
sp object with NA
, proj4string(x) <- CRS(NA)
, which
will fool the system to think that the data is in local planar coordinates.
This is probably not a good idea!
Edzer Pebesma edzer.pebesma@uni-muenster.de, Roger Bivand
run <- FALSE if (require("spatstat.geom", quietly=TRUE)) run <- TRUE if (run) { data(meuse.riv) mr <- Line(meuse.riv) mr_psp <- as(mr, "psp") mr_psp } if (run) { plot(mr_psp) } if (run) { xx_back <- as(mr_psp, "SpatialLines") plot(xx_back) } if (run) { xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1], proj4string=CRS("+proj=utm +zone=33 +ellps=WGS84")) xx_psp <- as(xx["LENGTH"], "psp") xx_psp } if (run) { plot(xx_psp) } if (run) { xx_back <- as(xx_psp, "SpatialLines") plot(xx_back) } if (run) { xx <- readShapeLines(system.file("shapes/fylk-val-ll.shp", package="maptools")[1], proj4string=CRS("+proj=longlat +ellps=WGS84")) try(xx_psp <- as(xx["LENGTH"], "psp")) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.