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

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)