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]]

_______________________________________________

R-sig-Geo mailing list

[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo