rotates polygon by specified angle
rotate.polygon( p, angle = 45, sp = FALSE, anchor = c("center", "lower.left", "upper.right") )
p | A polygon object of sf or sp class |
---|---|
angle | Rotation angle in degrees |
sp | (FALSE | TRUE) Output sp class object |
anchor | Location to rotate polygon on options are "center", "lower.left" and "upper.right" |
an sp or sf polygon object with rotated polygon
The anchor is the location that the rotation is anchored to. The center is the centroid where the lower.left and upper.right are based on the min or max of the coordinates respectively.
library(sp) library(rgeos) data(meuse) coordinates(meuse) <- ~x+y e <- gConvexHull(meuse) e30 <- rotate.polygon(e, angle=30, sp=TRUE) plot(e, main="rotated 30 degrees")