# NOT RUN {
# 1. create a polygon programmatically
coords <- data.frame(x = c(0, 40, 40, 0),
y = c(0, 0, 40, 40))
# if no window is set, the bounding box will be set as window
aGeom <- gs_polygon(anchor = coords)
visualise(aGeom)
# derive a regular polygon from the coordinates
aPolygon <- gs_polygon(anchor = coords, vertices = 6, regular = TRUE)
visualise(aPolygon, linecol = "green")
visualise(aGeom, new = FALSE)
# the vertices are plottet relative to the window
window <- data.frame(x = c(-50, 50),
y = c(-50, 50))
aPolygon <- setWindow(x = aPolygon, to = window)
visualise(aPolygon, fillcol = "deeppink")
# using a geom as anchor retains its properties (such as the window)
aRectangle <- gs_rectangle(anchor = aPolygon)
visualise(aRectangle, new = FALSE)
# 2. sketch a hexagon
if(dev.interactive()){
aHexagon <- gs_hexagon(features = 1)
visualise(aHexagon, linecol = "deeppink", linetype = 2, new = FALSE)
}
# }
Run the code above in your browser using DataLab