Learn R Programming

geometr (version 0.2.5)

gt_scale: Scale geoms

Description

Scale the vertex values of geoms to a values range or so that they are either relative to the @window slot, or absolute values.

Usage

gt_scale(geom, range = NULL, to = "relative")

Arguments

geom

[geom(.)] the object to be scaled.

range

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

to

[character(1)] the scale to which the coordinates should be transformed; possible are "relative" and "absolute"; ignored in case range != NULL.

Value

Scaled geom.

See Also

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

Examples

Run this code
# NOT RUN {
coords <- data.frame(x = c(40, 70, 70, 50, 40),
                     y = c(40, 40, 60, 70, 40),
                     fid = 1)
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
aGeom <- gs_polygon(anchor = coords, window = window)

# change to relative scale and back to absolute
(relCoords <- gt_scale(geom = aGeom, to = "relative"))
gt_scale(geom = relCoords, to = "absolute")

# scale to another range
gt_scale(geom = aGeom, range = list(x = c(0, 100), y = c(10, 90)))

# }

Run the code above in your browser using DataLab