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).

as.ppp(X, ..., fatal=TRUE)
  as.ppp(X, W, ..., fatal=TRUE)
Data which will be converted into a point pattern
Data which define a window for the pattern when X does not contain a window
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"spp"as defined in thespatiallibrary
  • an object of class"quad"representing a quadrature scheme (seequad.object)
  • a two-column matrix
  • a structure with entriesx,y
In the last two cases, we need the second argument 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.

An spp object is the representation of a point pattern in the spatial library. Our implementation recognises the following formats:

  • a structure with entriesx,yxl,xu,yl,yu
  • a structure with entriesx,yandarea, whereareais a structure with entriesxl,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", "quad", "matrix" 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.


as.ppp(X, ..., fatal=TRUE) ## S3 method for class 'ppp': as.ppp(X, \dots, fatal=TRUE) ## S3 method for class 'quad': as.ppp(X, \dots, fatal=TRUE) ## S3 method for class 'matrix': as.ppp(X, W=NULL, \dots, fatal=TRUE) ## S3 method for class 'default': as.ppp(X, W=NULL, \dots, fatal=TRUE)


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.

See Also

ppp, ppp.object, as.owin, owin.object

  • as.ppp
  • as.ppp.ppp
  • as.ppp.quad
  • as.ppp.matrix
  • as.ppp.default
 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
 towns <- ppinit("towns.dat")
 pp <- as.ppp(towns)   # converted to our format
Documentation reproduced from package spatstat, version 1.9-0, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.