Skip to content
Prev 26665 / 29559 Next

intersections to individual polygons

Agustin Lobo writes:
First convert the SpatialPolygons to spatstat 'owin' objects using as.owin.


If there are two polygons A and B, you can just use intersect.owin and setminus.owin to get what you want:

      AandB <- intersect.owin(A, B )

      AnotB <- setminus.owin(A, B )

      BnotA <- setminus.owin(B, A)


If there are several windows, make a list P containing the windows.

Then call

     Z <- kaleido(P)

     plot(Z, do.col=TRUE)

using the following code. The result Z is a tessellation. Extract the individual pieces as tiles(Z).


      kaleido <- function(P) {

           U <- union.owin(as.solist(P))

            V <- lapply(P, onesplit, U=U)

            Z <- Reduce(intersect.tess, V)

            return(Z)

      }

      onesplit <- function(X, U) tess(tiles=list(A=X, NotA=setminus.owin(U, X)), W=U)



Prof Adrian Baddeley DSc FAA

John Curtin Distinguished Professor

Department of Mathematics and Statistics

Curtin University, Perth, Western Australia