as.psp: Coercion between sp objects and spatstat psp objects

Description Usage Arguments Methods Warning Author(s) Examples

Description

Functions to convert between spatstats planar segment pattern (psp) format and various sp line formats. S4-style as() coercion can be used as well.

Usage

1
2
3
4
5
6
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)

Arguments

from

object to coerce from

...

ignored

window

window of class owin as defined in the spatstat package

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

Methods

coerce

signature(from = "Line", to = "psp")

coerce

signature(from = "Lines", to = "psp")

coerce

signature(from = "SpatialLines", to = "psp")

coerce

signature(from = "SpatialLinesDataFrame", to = "psp")

coerce

signature(from = "psp", to = "SpatialLines")

Warning

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!

Author(s)

Edzer Pebesma edzer.pebesma@uni-muenster.de, Roger Bivand

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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"))
}

maptools documentation built on Sept. 7, 2021, 5:09 p.m.