gt_scale: Scale geometric objects

Description Usage Arguments Value See Also Examples

View source: R/gt_scale.R

Description

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

Usage

1
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(.)]
if only a subset of features shall be scaled, specify that here.

update

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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 documentation built on March 30, 2021, 5:13 p.m.