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

gt_scale

Scale geometric objects


Description

Scale the vertex values of geometric objects to a values range.

Usage

gt_scale(obj, range = NULL, fid = NULL, update = TRUE)

Arguments

obj

[geometric object(1)]
the object to be scaled.

range

[data.frame(2)]
vector of length two for both of the x and y dimension to which the values should be scaled.

fid

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

update

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

Value

geom of the scaled obj.

See Also

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

Examples

# rescale to values between -10 and 10
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_scale(obj = gtGeoms$polygon, update = FALSE,
                    range = data.frame(x = c(-10, 10), y = c(-10, 10)))
visualise(geom = newPoly, linecol = "green", new = FALSE)

# rescale a single feature
visualise(gtGeoms$polygon, linewidth = 3)
newPoly <- gt_scale(obj = gtGeoms$polygon, update = FALSE, fid = 2,
                    range = data.frame(x = c(-10, 10), y = c(-10, 10)))
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.