geo_rotate: Rotate geometric objects

View source: R/geo_rotate.R

geo_rotateR Documentation

Rotate geometric objects

Description

Rotate geometric objects by a certain angle about center coordinates

Usage

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

Arguments

obj

gridded(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: geo_filter(), geo_locate(), geo_pull(), geo_reflect(), geo_scale(), geo_skew(), geo_stretch(), geo_translate()

Examples

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

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

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

EhrmannS/geometr documentation built on Jan. 31, 2024, 9:13 a.m.