Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Extract.psp

Extract Subset of Line Segment Pattern


Description

Extract a subset of a line segment pattern.

Usage

## S3 method for class 'psp'
x[i, j, drop, ..., fragments=TRUE]

Arguments

x

A two-dimensional line segment pattern. An object of class "psp".

i

Subset index. Either a valid subset index in the usual R sense, indicating which segments should be retained, or a window (an object of class "owin") delineating a subset of the original observation window.

j

Redundant - included for backward compatibility.

drop

Ignored. Required for compatibility with generic function.

...

Ignored.

fragments

Logical value indicating whether to retain all pieces of line segments that intersect the new window (fragments=TRUE, the default) or to retain only those line segments that lie entirely inside the new window (fragments=FALSE).

Details

These functions extract a designated subset of a line segment pattern.

The function [.psp is a method for [ for the class "psp". It extracts a designated subset of a line segment pattern, either by “thinning” (retaining/deleting some line segments of a line segment pattern) or “trimming” (reducing the window of observation to a smaller subregion and clipping the line segments to this boundary) or both.

The pattern will be “thinned” if subset is specified. The line segments designated by subset will be retained. Here subset can be a numeric vector of positive indices (identifying the line segments to be retained), a numeric vector of negative indices (identifying the line segments to be deleted) or a logical vector of length equal to the number of line segments in the line segment pattern x. In the latter case, the line segments for which subset[i]=TRUE will be retained, and the others will be deleted.

The pattern will be “trimmed” if window is specified. This should be an object of class owin specifying a window of observation to which the line segment pattern x will be trimmed. Line segments of x lying inside the new window will be retained unchanged. Line segments lying partially inside the new window and partially outside it will, by default, be clipped so that they lie entirely inside the window; but if fragments=FALSE, such segments will be removed.

Both “thinning” and “trimming” can be performed together.

Value

A line segment pattern (of class "psp").

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

a <- psp(runif(20),runif(20),runif(20),runif(20), window=owin())
    plot(a)
  # thinning
    id <- sample(c(TRUE, FALSE), 20, replace=TRUE)
    b <- a[id]
    plot(b, add=TRUE, lwd=3)
 # trimming
    plot(a)
    w <- owin(c(0.1,0.7), c(0.2, 0.8))
    b <- a[w]
    plot(b, add=TRUE, col="red", lwd=2)
    plot(w, add=TRUE)
    u <- a[w, fragments=FALSE]
    plot(u, add=TRUE, col="blue", lwd=3)

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.