I'm looking for a quick way to move around my polygons in R
... I'd like to move the my polygon based on it's center to a new center.
library(sf)
library(ggplot2)
theta <- (0:6) * pi / 3
hexagon <- data.frame(
x = sin(theta),
y = cos(theta))
poly <- hexagon %>%
st_as_sf(coords = c("x", "y")) %>%
mutate(geometry = st_combine(geometry))%>%
st_cast("POLYGON")
How can I move the polygon to the new center (here: red point)?
poly %>%
ggplot()
geom_sf()
geom_point(data=data.frame(x=10, y=10), aes(x, y), color="red")
Thanks!
CodePudding user response: