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

intersect.owin

Intersection, Union or Set Subtraction of Windows


Description

Yields the intersection, union or set subtraction of windows.

Usage

intersect.owin(..., fatal=FALSE, p)
   union.owin(..., p)
   setminus.owin(A, B, ..., p)

Arguments

A,B

Windows (objects of class "owin").

...

Windows, or arguments passed to as.mask to control the discretisation.

fatal

Logical. Determines what happens if the intersection is empty.

p

Optional list of parameters passed to polyclip to control the accuracy of polygon geometry.

Details

The function intersect.owin computes the intersection between the windows given in ..., while union.owin computes their union. The function setminus.owin computes the intersection of A with the complement of B.

For intersect.owin and union.owin, the arguments ... must be either

  • window objects of class "owin",

  • data that can be coerced to this class by as.owin),

  • lists of windows, of class "solist",

  • named arguments of as.mask to control the discretisation if required.

For setminus.owin, the arguments ... must be named arguments of as.mask.

If the intersection is empty, then if fatal=FALSE the result is an empty window or NULL, while if fatal=TRUE an error occurs.

Value

A window (object of class "owin") or possibly NULL.

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

# rectangles
   u <- unit.square()
   v <- owin(c(0.5,3.5), c(0.4,2.5))
# polygon
   data(letterR)
# mask
   m <- as.mask(letterR)

# two rectangles
   intersect.owin(u, v) 
   union.owin(u,v)
   setminus.owin(u,v)

# polygon and rectangle
   intersect.owin(letterR, v)
   union.owin(letterR,v)
   setminus.owin(letterR,v)

# mask and rectangle
   intersect.owin(m, v)
   union.owin(m,v)
   setminus.owin(m,v)

# mask and polygon
   p <- rotate(v, 0.2)
   intersect.owin(m, p)
   union.owin(m,p)
   setminus.owin(m,p)

# two polygons
   A <- letterR
   B <- rotate(letterR, 0.2)
   plot(boundingbox(A,B), main="intersection")
   w <- intersect.owin(A, B)
   plot(w, add=TRUE, col="lightblue")
   plot(A, add=TRUE)
   plot(B, add=TRUE)

   plot(boundingbox(A,B), main="union")
   w <- union.owin(A,B)
   plot(w, add=TRUE, col="lightblue")   
   plot(A, add=TRUE)
   plot(B, add=TRUE)

   plot(boundingbox(A,B), main="set minus")
   w <- setminus.owin(A,B)
   plot(w, add=TRUE, col="lightblue")   
   plot(A, add=TRUE)
   plot(B, add=TRUE)

# intersection and union of three windows
   C <- shift(B, c(0.2, 0.3))
   plot(union.owin(A,B,C))
   plot(intersect.owin(A,B,C))

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.