Divide Point Pattern into Sub-patterns

Divides a point pattern into several sub-patterns, according to their marks, or according to any user-specified grouping.

manip, methods, spatial
## S3 method for class 'ppp':
split(x, f = marks(x), drop=FALSE, un=NULL, ...)
  ## S3 method for class 'ppp':
split(x, f = marks(x), drop=FALSE, un=missing(f), ...) <- value
A two-dimensional point pattern. An object of class "ppp".
Data determining the grouping. Either a factor, a pixel image with factor values, or a tessellation.
Logical. Determines whether empty groups will be deleted.
Logical. Determines whether the resulting subpatterns will be unmarked (i.e. whether marks will be removed from the points in each subpattern).
Other arguments are ignored.
List of point patterns.

The function split.ppp divides up the points of the point pattern x into several sub-patterns according to the values of f. The result is a list of point patterns. The argument f may be

  • a factor, of length equal to the number of points inx. The levels offdetermine the destination of each point inx. Theith point ofxwill be placed in the sub-patternsplit.ppp(x)$lwherel = f[i].
  • a pixel image (object of class"im") with factor values. The pixel value offat each point ofxwill be used as the classifying variable.
  • a tessellation (object of class"tess"). Each point ofxwill be classified according to the tile of the tessellation into which it falls.
If f is missing, then x must be a multitype point pattern (a marked point pattern whose marks vector is a factor). Then the effect is that the points of each type are separated into different point patterns.

Some of the sub-patterns created by the split may be empty. If drop=TRUE, then empty sub-patterns will be deleted from the list. If drop=FALSE then they are retained.

The argument un determines how to handle marks in the case where x is a marked point pattern. If un=TRUE then the marks of the points will be discarded when they are split into groups, while if un=FALSE then the marks will be retained. The result of split.ppp has class "splitppp" and can be plotted using plot.splitppp.

The assignment function split<-.ppp updates the point pattern x so that it satisfies split(x, f, drop, un) = value. The argument value is expected to be a list of point patterns, one for each level of f. These point patterns are expected to be compatible with the type of data in the original pattern x.

Splitting can also be undone by the function superimpose.


  • The value of split.ppp is a list of point patterns. The components of the list are named by the levels of f. The list also has the class "splitppp".

    The assignment form split<-.ppp returns the updated point pattern x.

See Also

cut.ppp, plot.splitppp, superimpose, im, tess, ppp.object

  • split.ppp
  • split<-.ppp
# (1) Splitting by marks

# Multitype point pattern: separate into types
 u <- split(amacrine)

# plot them

# the following are equivalent:
 amon <- split(amacrine)$on
 amon <- unmark(amacrine[amacrine$marks == "on"])
# the following are equivalent:
 amon <- split(amacrine, un=FALSE)$on
 amon <- amacrine[amacrine$marks == "on"]
# Scramble the locations of the 'on' cells
 u <- split(amacrine)
 u$on <- runifpoint(amon$n, amon$window)
 split(amacrine) <- u

# Point pattern with continuous marks
 <testonly># smaller dataset
	longleaf <- longleaf[seq(1, longleaf$n, by=80)]</testonly>
 # cut the range of tree diameters into three intervals
 # using cut.ppp
 long3 <- cut(longleaf, breaks=3)
 # now split them
 long3split <- split(long3)

# (2) Splitting by a factor

# Unmarked point pattern
# cut & split according to nearest neighbour distance
  f <- cut(nndist(swedishpines), 3)
  u <- split(swedishpines, f)

# (3) Splitting over a tessellation
   tes <- tess(xgrid=seq(0,96,length=5),ygrid=seq(0,100,length=5))
   v <- split(swedishpines, tes)
Documentation reproduced from package spatstat, version 1.16-3, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.