我必须同意@Spacedman 的观点,即您的问题可以使用有关该问题的更多细节。下面是使用spatstat
. 包如sf
,sp
等肯定具有相同的功能。
盒子中的两个重叠(多边形近似)圆盘:
library(spatstat)
A <- disc()
B <- shift(A, vec = c(1.6,0))
box <- boundingbox(union.owin(A,B))
plot(box, main = "")
B <- shift(A, vec = c(1.6,0))
colA <- rgb(1,0,0,.5)
colB <- rgb(0,1,0,.5)
plot(A, col = colA, add = TRUE, border = colA)
plot(B, col = colB, add = TRUE, border = colB)
设置差异:
AnotB <- setminus.owin(A, B)
BnotA <- setminus.owin(B, A)
plot(box, main = "")
plot(AnotB, col = colA, add = TRUE, border = colA)
plot(BnotA, col = colB, add = TRUE, border = colB)
集差的凸包:
AA <- convexhull(AnotB)
BB <- convexhull(BnotA)
plot(box, main = "")
plot(AA, col = colA, add = TRUE, border = colA)
plot(BB, col = colB, add = TRUE, border = colB)
如果要查找交点:
edgesA <- edges(A)
edgesB <- edges(B)
x <- crossing.psp(edgesA,edgesB)
plot(box, main = "")
plot(A, col = colA, add = TRUE, border = colA)
plot(B, col = colB, add = TRUE, border = colB)
plot(x, add = TRUE, pch = 20, col = "blue", cex = 3)