How to union intersecting polygons (perfect circles) like in the following picture:
So far, I used rgeos and sf, but couldn´t identiy a simple way yet.
library(rgeos)
library(sp)
pts <- SpatialPoints(cbind(c(2,3), c(1,1)))
plot(pts)
pol <- gBuffer(pts, width=0.6, byid=TRUE)
plot(pol)
@ Ege Rubak provided the hint to create a convex hull around the differences of circles. with rgeos the solution looks like foollowing code. However, I struggle receiving the solution in a single step.
gSym1 <- gDifference(pol[1,],pol[2,])
gch1 <- gConvexHull(gSym1)
gSym2 <- gDifference(pol[2,],pol[1,])
gch2 <- gConvexHull(gSym2)
plot(gch1)
plot(gch2, add=TRUE)
I must agree with @Spacedman that your question could use a lot more detail about the problem. Below is a quick approach for two circles using
spatstat
. Packages assf
,sp
, etc. surely have the same capabilities.Two overlapping (polygonal appoximations of) discs in a box:
Set differences:
Convex hulls of set differences:
If you want to find the intersection points: