cut.ppp: Classify Points in a Point Pattern

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cut.ppp.R

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

1
2
  ## 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, a window, a tessellation, or a string giving the name of a column of marks or the name of a spatial coordinate.

...

Arguments passed to cut.default. They determine the breakpoints for the mapping from numerical values in z to factor values in the output. See cut.default.

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

The default is to take z to be the vector of marks in x (or the first column in the data frame of marks of x, if it is a data frame). 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 operators [.ppp or subset.ppp instead.

Value

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

Author(s)

\spatstatAuthors

.

See Also

cut, ppp.object, tess

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 # (1) cutting based on numeric marks of point pattern
 
 trees <- longleaf
 # Longleaf Pines data
 # the marks are positive real numbers indicating tree diameters.

 
 if(interactive()) {
 plot(trees)
 }

 # cut the range of tree diameters into three intervals
 long3 <- cut(trees, breaks=3)
 if(interactive()) {
 plot(long3)
 }

 # adult trees defined to have diameter at least 30 cm
 long2 <- cut(trees, 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

 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)

 # (4) inside/outside a given region
 with(murchison, cut(gold, greenstone))

 # (5) multivariate marks
 finpines
 cut(finpines, "height", breaks=4)

spatstat.geom documentation built on April 15, 2021, 9:06 a.m.