as.psp {spatstat} | R Documentation |
Tries to coerce any reasonable kind of data to a line segment pattern
(an object of class "psp"
)
for use by the spatstat package.
as.psp(x, ..., from=NULL, to=NULL) ## S3 method for class 'psp': as.psp(x, ..., fatal=TRUE) ## S3 method for class 'data.frame': as.psp(x, ..., window=NULL, marks=NULL, fatal=TRUE) ## S3 method for class 'matrix': as.psp(x, ..., window=NULL, marks=NULL, fatal=TRUE) ## S3 method for class 'owin': as.psp(x, ..., fatal=TRUE) ## Default S3 method: as.psp(x, ..., window=NULL, marks=NULL, fatal=TRUE)
x |
Data which will be converted into a line segment pattern |
window |
Data which define a window for the pattern
when x does not contain a window |
... |
Ignored. |
marks |
(Optional) vector of marks for the pattern |
fatal |
Logical value. See Details. |
from,to |
Point patterns (object of class "ppp" )
containing the first and second endpoints (respectively) of each
segment. Incompatible with x .
|
Converts the dataset x
to a line segment pattern
(an object of class "psp"
; see psp.object
for
an overview).
This function is normally used to convert an existing line segment pattern
dataset, stored in another format, to the "psp"
format.
To create a new point pattern from raw data such as x,y
coordinates, it is normally easier to use the creator function
psp
.
The dataset x
may be:
"psp"
x0, y0, x1, y1
that will be interpreted as the coordinates of the endpoints
of the segments
x0, y0, x1, y1
of the endpoints of the segments
xmid, ymid, length, angle
that will be interpreted as the coordinates of the segment
midpoints, the lengths of the segments, and the orientations of the
segments in radians
x0, y0, x1, y1
or elements named xmid, ymid, length, angle
which will be interpreted as above.
"owin"
representing a spatial window;
it must be of type "rectangle"
or "polygonal"
.
The boundary edges of the window will be extracted as a line segment
pattern.
Alternatively, you may specify two point patterns
from
and to
containing the first and second endpoints
of the line segments.
The argument window
is converted to a window object
by the function as.owin
.
The argument fatal
indicates what to do when
the data cannot be converted to a line segment pattern.
If fatal=TRUE
, a fatal error
will be generated; if fatal=FALSE
, the
value NULL
is returned.
The function as.psp
is generic, with methods for the
classes "psp"
, "data.frame"
, "matrix"
and a default method.
Point pattern datasets can also be created by the function
psp
.
An object of class "psp"
(see psp.object
)
describing the line segment pattern and its window of observation.
The value NULL
may also be returned; see Details.
Adrian Baddeley adrian@maths.uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner rolf@math.unb.ca http://www.math.unb.ca/~rolf
psp
,
psp.object
,
as.owin
,
owin.object
mat <- matrix(runif(40), ncol=4) a <- as.psp(mat, window=owin()) stuff <- list(xmid=runif(10), ymid=runif(10), length=rep(0.1, 10), angle=runif(10, 0, 2 * pi)) a <- as.psp(stuff, window=owin()) b <- as.psp(from=runifpoint(10), to=runifpoint(10))