# NOT RUN {
# 1. create a polygon programmatically
coords <- data.frame(x = c(40, 70, 70, 50),
y = c(40, 40, 60, 70))
# if no window is set, the bounding box will be set as window
(aGeom <- gs_polygon(anchor = coords))
# the vertices are plottet relative to the window
library(magrittr)
window <- data.frame(x = c(0, 80),
y = c(0, 80))
gs_polygon(anchor = coords, vertices = 6, window = window,
regular = TRUE) %>%
visualise(linecol = "green")
# when a geom is used in 'anchor', its properties are passed on
aGeom <- setWindow(x = aGeom, to = window)
gs_polygon(anchor = aGeom) %>%
visualise(geom = ., fillcol = "deeppink")
gs_rectangle(anchor = aGeom) %>%
visualise(geom = ., new = FALSE)
# }
# NOT RUN {
# 2. sketch a hexagon by clicking into a template
gs_hexagon(sketch = gtRasters$continuous) %>%
visualise(geom = ., linecol = "deeppink", linetype = 2, new = FALSE)
# }
Run the code above in your browser using DataLab