as.ppp {spatstat} | R Documentation |
Tries to coerce any reasonable kind of data to a point pattern
(an object of class "ppp"
)
for use by the spatstat package).
as.ppp(X, ..., fatal=TRUE) ## S3 method for class 'ppp' as.ppp(X, ..., fatal=TRUE) ## S3 method for class 'psp' as.ppp(X, ..., fatal=TRUE) ## S3 method for class 'quad' as.ppp(X, ..., fatal=TRUE) ## S3 method for class 'matrix' as.ppp(X, W=NULL, ..., fatal=TRUE) ## S3 method for class 'data.frame' as.ppp(X, W=NULL, ..., fatal=TRUE) ## S3 method for class 'influence.ppm' as.ppp(X, ...) ## Default S3 method: as.ppp(X, W=NULL, ..., fatal=TRUE)
X |
Data which will be converted into a point pattern |
W |
Data which define a window for the pattern
when |
... |
Ignored. |
fatal |
Logical value. See Details. |
Converts the dataset X
to a point pattern
(an object of class "ppp"
; see ppp.object
for
an overview).
This function is normally used to convert an existing point pattern
dataset, stored in another format, to the "ppp"
format.
To create a new point pattern from raw data such as x,y
coordinates, it is normally easier to use the creator function
ppp
.
The dataset X
may be:
an object of class "ppp"
an object of class "psp"
an object of class "spp"
as defined in the
spatial library
an object of class "quad"
representing a quadrature scheme
(see quad.object
)
a matrix or data frame with at least two columns
a structure with entries x
, y
which are numeric vectors
of equal length
a numeric vector of length 2, interpreted as the coordinates of a single point.
In the last three cases, we need the second argument W
which is converted to a window object
by the function as.owin
.
In the first four cases, W
will be ignored.
If X
is a line segment pattern (an object of class psp
)
the point pattern returned consists of the endpoints of the segments.
If X
is marked then the point pattern returned will also be
marked, the mark associated with a point being the mark of the segment
of which that point was an endpoint.
If X
is a matrix or data frame, the first and second columns will
be interpreted as the x and y coordinates respectively.
Any additional columns will be interpreted as marks.
The argument fatal
indicates what to do when
W
is missing and X
contains no
information about the window. If fatal=TRUE
, a fatal error
will be generated; if fatal=FALSE
, the
value NULL
is returned.
An spp
object is the representation of a point pattern
in the spatial library. Our implementation recognises
the following formats:
a structure with entries x
, y
xl
, xu
, yl
, yu
a structure with entries
x
, y
and area
,
where area
is a structure with entries
xl
, xu
, yl
, yu
(used in spatial versions 1 to 6 and version 7.1 respectively)
where x
and y
are vectors of equal length
giving the point coordinates, and xl
, xu
, yl
,
yu
are numbers giving the dimensions of a rectangular window.
The function as.ppp
is generic, with methods for the
classes "ppp"
, "psp"
, "quad"
, "matrix"
,
"data.frame"
and a default method.
Point pattern datasets can also be created by the function
ppp
.
An object of class "ppp"
(see ppp.object
)
describing the point pattern and its window of observation.
The value NULL
may also be returned; see Details.
If the format of spp
objects is changed in future versions
of the spatial library, then as.ppp
may not be able to
interpret them. It currently handles all versions of spatial
up to 7.1-4.
Adrian Baddeley Adrian.Baddeley@csiro.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner r.turner@auckland.ac.nz
ppp
, ppp.object
, as.owin
,
owin.object
xy <- matrix(runif(40), ncol=2) pp <- as.ppp(xy, c(0,1,0,1)) # Venables-Ripley format # check for 'spatial' package spatialpath <- .find.package("spatial", quiet=TRUE) if(length(spatialpath) != 0) { require(spatial) towns <- ppinit("towns.dat") pp <- as.ppp(towns) # converted to our format detach(package:spatial) } xyzt <- matrix(runif(40), ncol=4) Z <- as.ppp(xyzt, square(1))