
geom
sScale the vertex values of geom
s to a values range or so that they are
either relative to the @window
slot, or absolute values.
gt_scale(geom, range = NULL, to = "relative")
[geom(.)
] the object to be scaled.
[list(2)
] vector of length two for both of the
x
and y
dimension to which the values should be scaled.
[character(1)
] the scale to which the coordinates should
be transformed; possible are "relative"
and "absolute"
;
ignored in case range != NULL
.
Scaled geom
.
Other geometry tools:
gt_reflect()
,
gt_rotate()
,
gt_sketch()
,
gt_skew()
,
gt_stretch()
,
gt_translate()
# 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