Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gt_translate

Translate geometric objects


Description

Translate geometric objects by adding a constant in x and y dimension.

Usage

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

Arguments

obj

[geometric object(1)]
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(.)]
in case only a subset of features shall be translated, specify that here.

update

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

Value

geom of the mathematically translated obj.

See Also

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

Examples

# translate several features
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_translate(obj = gtGeoms$polygon, x = 5, y = c(-10, 5),
                        update = FALSE)
visualise(geom = newPoly, linecol = "green", new = FALSE)

# translate a single feature
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_translate(obj = gtGeoms$polygon, x = 5, fid = 2,
                        update = FALSE)
visualise(geom = newPoly, linecol = "green", new = FALSE)

geometr

Generate and Modify Interoperable Geometric Shapes

v0.2.10
GPL-3
Authors
Steffen Ehrmann [aut, cre] (<https://orcid.org/0000-0002-2958-0796>), Dan Sunday [cph] (fast point-in-polygon algorithm.)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.