[R] calculate area between intersecting polygons
Hans W Borchers
hwborchers at googlemail.com
Tue Oct 26 16:02:04 CEST 2010
Remko Duursma <remkoduursma <at> gmail.com> writes:
>
> Here is a different solution:
>
> library(gpclib)
> p1 <- as(poly1, "gpc.poly")
> p2 <- as(poly2, "gpc.poly")
>
> area.poly(p2) + area.poly(p1) - area.poly(union(p1,p2))
>
> I.e., take areas of both polygons and subtract the union (check
> plot(union(p1,p2)) ) to get the area of the intersection.
>
> greetings,
> Remko
Thanks for the hint. I didn't know that the "polygon clipping library" has
been packaged for R, I could have used it several time before. There are
too many package, though this time I admit it would have been easy to hit
upon it by searching CRAN carefully.
Hans Werner
Hans Werner
More information about the R-help
mailing list