Skip to content
Back to formatted view

Raw Message

Message-ID: <ME1PR01MB0659A87E19546D901A37A076A4420@ME1PR01MB0659.ausprd01.prod.outlook.com>
Date: 2018-07-03T03:44:13Z
From: Adrian Baddeley
Subject: intersections to individual polygons
In-Reply-To: <432980a8-4a26-c4f6-d78e-9a8efe6a9bf5@auckland.ac.nz>

Agustin Lobo writes:


>>> Given an SpatialPolygons DF with i.e. 2 intersecting polygons, A and B,
>>> is there a function that would split the original polygons into "onlyA", "onlyB" and
>>> "AintersectingB" polygons?


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



	[[alternative HTML version deleted]]