superimpose {spatstat.geom}R Documentation

Superimpose Several Geometric Patterns

Description

Superimpose any number of point patterns or line segment patterns.

Usage

  superimpose(...)

  ## S3 method for class 'ppp'
superimpose(..., W=NULL, check=TRUE)

  ## S3 method for class 'psp'
superimpose(..., W=NULL, check=TRUE)

  ## S3 method for class 'splitppp'
superimpose(..., W=NULL, check=TRUE)

  ## S3 method for class 'ppplist'
superimpose(..., W=NULL, check=TRUE)

  ## Default S3 method:
superimpose(...)

Arguments

...

Any number of arguments, each of which represents either a point pattern or a line segment pattern or a list of point patterns.

W

Optional. Data determining the window for the resulting pattern. Either a window (object of class "owin", or something acceptable to as.owin), or a function which returns a window, or one of the strings "convex", "rectangle", "bbox" or "none".

check

Logical value (passed to ppp or psp as appropriate) determining whether to check the geometrical validity of the resulting pattern.

Details

This function is used to superimpose several geometric patterns of the same kind, producing a single pattern of the same kind.

The function superimpose is generic, with methods for the class ppp of point patterns, the class psp of line segment patterns, and a default method. There is also a method for lpp, described separately in superimpose.lpp.

The dispatch to a method is initially determined by the class of the first argument in ....

The patterns are not required to have the same window of observation.

The window for the superimposed pattern is controlled by the argument W.

The arguments ... may be marked patterns. The marks of each component pattern must have the same format. Numeric and character marks may be “mixed”. If there is such mixing then the numeric marks are coerced to character in the combining process. If the mark structures are all data frames, then these data frames must have the same number of columns and identical column names.

If the arguments ... are given in the form name=value, then the names will be used as an extra column of marks attached to the elements of the corresponding patterns.

Value

For superimpose.ppp, a point pattern (object of class "ppp"). For superimpose.default, either a point pattern (object of class "ppp") or a list(x,y). For superimpose.psp, a line segment pattern (object of class "psp").

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Rolf Turner rolfturner@posteo.net.

See Also

concatxy, quadscheme.

Examples

  # superimposing point patterns
  p1  <- runifrect(30)
  p2  <- runifrect(42)
  s1  <- superimpose(p1,p2) # Unmarked pattern.
  p3  <- list(x=rnorm(20),y=rnorm(20))
  s2  <- superimpose(p3,p2,p1) # Default method gets called.
  s2a <- superimpose(p1,p2,p3) # Same as s2 except for order of points.
  s3  <- superimpose(clyde=p1,irving=p2) # Marked pattern; marks a factor
                                         # with levels "clyde" and "irving";
                                         # warning given.
  marks(p1) <- factor(sample(LETTERS[1:3],30,TRUE))
  marks(p2) <- factor(sample(LETTERS[1:3],42,TRUE))
  s5  <- superimpose(clyde=p1,irving=p2) # Marked pattern with extra column
  marks(p2) <- data.frame(a=marks(p2),b=runif(42))
  s6  <- try(superimpose(p1,p2)) # Gives an error.
  marks(p1) <- data.frame(a=marks(p1),b=1:30)
  s7  <- superimpose(p1,p2) # O.K.

  # how to make a 2-type point pattern with types "a" and "b"
  u <- superimpose(a = runifrect(10), b = runifrect(20))

  # how to make a 2-type point pattern with types 1 and 2
  u <- superimpose("1" = runifrect(10), "2" = runifrect(20))
 
  # superimposing line segment patterns
  X <- as.psp(matrix(runif(20), 5, 4), window=owin())
  Y <- as.psp(matrix(runif(40), 10, 4), window=owin())
  Z <- superimpose(X, Y)

  # being unreasonable
  ## Not run: 
   if(FALSE) {
    crud <- try(superimpose(p1,p2,X,Y)) # Gives an error, of course!
   }
  
## End(Not run)

[Package spatstat.geom version 3.2-9 Index]