gt_rotate: Rotate geometric objects

Description Usage Arguments Value See Also Examples

View source: R/gt_rotate.R

Description

Rotate geometric objects by a certain angle about center coordinates

Usage

1
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 by which geom shall be rotated (can be negative to rotate clockwise).

fid

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

update

[logical(1)]
whether or not to update the window slot after rotation.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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)

geometr documentation built on March 30, 2021, 5:13 p.m.