[R-sig-Geo] complement part of a polygon in another polygon

Adrian Baddeley adrian at maths.uwa.edu.au
Thu Jan 28 12:01:21 CET 2010


User 'rusers.sh' asks a question about the library 'spatstat':

 > intersect.owin() works for intersection.
 > Say polygon B located inside A. Is there any function in R for us to
 > get the complement part of  B in  polygon A?

See complement.owin.
Try
        Bcom <- complement.owin(B, frame=bounding.box(A))
        AminB <- intersect.owin(A, Bcom)

If you want the answer to be a polygon, you'll need to set 
spatstat.options(gpclib=TRUE), unless A is a rectangle.

Adrian Baddeley



More information about the R-sig-Geo mailing list