if (version_GEOS0() >= "3.9.0") {
x = readWKT(paste("GEOMETRYCOLLECTION(POLYGON((0 0,10 1,10 11,0 10,0 0)),",
"POLYGON((15 0,25 12,35 3,15 0)))"))
# Minimum rotated rectangles of both the square and circle independently
c1 = gMinumumRotatedRectangle(x,byid=TRUE)
# Minimum rotated rectangle of square and circle together
c2 = gMinumumRotatedRectangle(x)
opar <- par(mfrow=c(2,1))
plot(c1, border='red', lwd=2, lty=2)
plot(x,add=TRUE)
plot(c2, border='blue', lwd=2, lty=3)
plot(x,add=TRUE)
par(opar)
}
Run the code above in your browser using DataLab