as.ppp
From spatstat v1.3-2
by Adrian Baddeley
Convert Data To Class ppp
Tries to coerce any reasonable kind of data to a point pattern
(an object of class "ppp"
)
for use by the spatstat
package).
- Keywords
- spatial
Usage
as.ppp(X)
as.ppp(X, W)
as.ppp(X, fatal=TRUE)
Arguments
- X
- Data which will be converted into a point pattern
- W
- Data which define a default window for the pattern
- fatal
- Logical value. See Details.
Details
This function tries to coerce the data X
to a point pattern
(an object of class "ppp"
; see ppp.object
for
an overview). The optional argument W
is a default window for the
pattern; it is used only if a window is not specified in X
.
The data X
may be:
- an object of class
"ppp"
- an object of class
"spp"
as used in the Venables and Ripley packagespatial
- an object of class
"quad"
representing a quadrature scheme (seequad.object
) - a structure with entries
x
,y
(vectors of equal length) andxl
,xu
,yl
,yu
(numbers giving the dimensions of a rectangular window) - a two-column matrix
- a structure with entries
x
,y
W
which is converted to a window object
by the function as.owin
.
In the first three cases, W
will be ignored. 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.
Point pattern datasets can also be created by the function
ppp
.
Value
- An object of class
"ppp"
(seeppp.object
) describing the point pattern and its window of observation. The valueNULL
may also be returned; see Details.
synopsis
as.ppp(X, W=NULL, fatal=TRUE)
See Also
Examples
library(spatstat)
plot(c(0,1),c(0,1),type="n")
xy <- locator(20) # click on 20 points in plot window
pp <- as.ppp(xy, c(0,1,0,1))
w <- owin(c(0,1),c(0,1))
plot(w) # neater
xy <- locator(20) # click on 20 points in plot window
pp <- as.ppp(xy, w)
xy <- matrix(runif(40), ncol=2)
pp <- as.ppp(xy, c(0,1,0,1))
# Venables-Ripley format
sp <- list(x=runif(10), y=runif(10), xl=0, xu=1, yl=0, yu=1)
pp <- as.ppp(sp) # converted to our format
Community examples
Looks like there are no examples yet.