Learn R Programming

geometr (version 0.2.5)

gt_translate: Translate geoms

Description

Translate geoms by adding a constant in x and y-dimension.

Usage

gt_translate(geom = NULL, x = NULL, y = NULL, fid = NULL, update = TRUE)

Arguments

geom

[geom(.)] the object to translate.

x

[numeric(1)] the translation constant (offset) in x-dimension.

y

[numeric(1)] the translation constant (offset) in y-dimension.

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

Mathematically translated geom.

See Also

Other geometry tools: gt_reflect(), gt_rotate(), gt_scale(), gt_sketch(), gt_skew(), gt_stretch()

Examples

Run this code
# NOT RUN {
# the original object
coords <- data.frame(x = c(30, 60, 60, 40, 10, 40, 20),
                     y = c(40, 40, 60, 70, 10, 20, 40),
                     fid = c(1, 1, 1, 1, 2, 2, 2))
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
aGeom <- gs_polygon(anchor = coords, window = window)

# translate several geoms
visualise(geom = gt_translate(geom = aGeom, x = 5, y = list(-10, 5)))

# translate a single geom
visualise(geom = gt_translate(geom = aGeom, x = 5, fid = 1))
# }

Run the code above in your browser using DataLab