Learn R Programming

spatstat (version 1.20-2)

cut.ppp: Classify Points in a Point Pattern

Description

Classifies the points in a point pattern into distinct types according to the numerical marks in the pattern, or according to another variable.

Usage

## S3 method for class 'ppp':
cut(x, z=marks(x), ...)

Arguments

x
A two-dimensional point pattern. An object of class "ppp".
z
Data determining the classification. A numeric vector, a factor, a pixel image, or a tessellation. Defaults to the vector of marks of the point pattern.
...
Arguments passed to cut.default. They determine the breakpoints for the mapping from numerical values in z to factor values in the output. See

Value

  • A multitype point pattern, that is, a point pattern object (of class "ppp") with a marks vector that is a factor.

Details

This function has the effect of classifying each point in the point pattern x into one of several possible types. The classification is based on the dataset z, which may be either
  • a factor (of length equal to the number of points inz) determining the classification of each point inx. Levels of the factor determine the classification.
  • a numeric vector (of length equal to the number of points inz). The range of values ofzwill be divided into bands (the number of bands is determined by...) andzwill be converted to a factor usingcut.default.
  • a pixel image (object of class"im"). The value ofzat each point ofxwill be used as the classifying variable.
  • a tessellation (object of class"tess", seetess). Each point ofxwill be classified according to the tile of the tessellation into which it falls.
The default is to take z to be the vector of marks in x. If the marks are numeric, then the range of values of the numerical marks is divided into several intervals, and each interval is associated with a level of a factor. The result is a marked point pattern, with the same window and point locations as x, but with the numeric mark of each point discretised by replacing it by the factor level. This is a convenient way to transform a marked point pattern which has numeric marks into a multitype point pattern, for example to plot it or analyse it. See the examples.

To select some points from a point pattern, use the subset operator [.ppp instead.

See Also

cut, ppp.object, tess

Examples

Run this code
# (1) cutting based on numeric marks of point pattern
 
 data(longleaf)
 # Longleaf Pines data
 # the marks are positive real numbers indicating tree diameters.

 <testonly># smaller dataset
	longleaf <- longleaf[seq(1, longleaf$n, by=80)]</testonly>
 plot(longleaf)

 # cut the range of tree diameters into three intervals
 long3 <- cut(longleaf, breaks=3)
 plot(long3)

 # adult trees defined to have diameter at least 30 cm
 long2 <- cut(longleaf, breaks=c(0,30,100), labels=c("Sapling", "Adult"))
 plot(long2)
 plot(long2, cols=c("green","blue"))

 # (2) cutting based on another numeric vector
 # Divide Swedish Pines data into 3 classes
 # according to nearest neighbour distance

 data(swedishpines)
 plot(cut(swedishpines, nndist(swedishpines), breaks=3))

 # (3) cutting based on tessellation
 # Divide Swedish Pines study region into a 4 x 4 grid of rectangles
 # and classify points accordingly

 tes <- tess(xgrid=seq(0,96,length=5),ygrid=seq(0,100,length=5))
 plot(cut(swedishpines, tes))
 plot(tes, lty=2, add=TRUE)

Run the code above in your browser using DataLab