How to calculate the area of polygon overlap in R?

前端 未结 2 859
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 23:46

Does anyone know how to calculate the area in common between 2 or more polygons in R? I would like to have the output of such a calculation be the coordinates of a new polyg

2条回答
  •  心在旅途
    2020-12-15 00:17

    Just thought I would add the solution that I eventually used - the joinPolys function from the PBSmapping package.

    Example:

    library(PBSmapping)
    p1 <- data.frame(PID=rep(1, 4), POS=1:4, X=c(1,1,6,6), Y=c(1,3,3,1))
    p2 <- data.frame(PID=rep(2, 5), POS=1:5, X=c(4,4,8,8,6), Y=c(2,4,4,2,1))
    p3 <- joinPolys(p1,p2)
    x11()
    par(mar=c(3,3,1,1))
    plot(1,1,ylim=c(0,5),xlim=c(0,9), t="n", xlab="", ylab="")
    polygon(p1$X, p1$Y, border=2)
    polygon(p2$X, p2$Y)
    polygon(p3$X, p3$Y, col=rgb(0,0,1,0.2))
    

    enter image description here

提交回复
热议问题