Rotate geometric objects by a certain angle about center coordinates

gt_rotate(obj, x = NULL, y = NULL, angle = NULL, fid = NULL, update = TRUE)

Arguments

obj

[geometric object(1)]
the object to rotate.

x

[numeric(1)]
the x position(s) to rotate about.

y

[numeric(1)]
the y position(s) to rotate about.

angle

[numeric(1)]
the counter-clockwise angle(s) by which obj shall be rotated (can be negative to rotate clockwise).

fid

[integerish(.)]
in case only a subset of features shall be rotated, specify that here.

update

[logical(1)]
whether or not to update the window slot of the resulting geom.

Value

geom of the rotated obj.

See also

Other geometry tools: gt_filter(), gt_locate(), gt_pull(), gt_reflect(), gt_scale(), gt_skew(), gt_stretch(), gt_translate()

Examples

# rotate all geoms
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_rotate(obj = gtGeoms$polygon, x = 0, y = 0, angle = 135,
                     update = FALSE)
visualise(geom = newPoly, linecol = "green", new = FALSE)


# rotate a single geom
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_rotate(obj = gtGeoms$polygon, x = -10, y = 0, angle = -180,
                     update = FALSE, fid = 2)
visualise(geom = newPoly, linecol = "green", new = FALSE)


# rotate different geoms about different centers by different angles
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_rotate(obj = gtGeoms$polygon,
                     x = c(0, -10),
                     y = c(-10, 0),
                     angle = c(75, -135),
                     update = FALSE)
visualise(geom = newPoly, linecol = "green", new = FALSE)