gs_line: Create a line 'geom'

Description Usage Arguments Details Value See Also Examples

View source: R/gs_line.R

Description

Create a line geometry (of class geom) either by specifying anchor values or by sketching it.

Usage

1
gs_line(anchor = NULL, window = NULL, features = 1, vertices = 2, ...)

Arguments

anchor

[geom(1)|data.frame(1)]
Object to derive the geom from. It must include column names x, y and optionally a custom fid.

window

[data.frame(1)]
in case the reference window deviates from the bounding box of anchor (minimum and maximum values), specify this here.

features

[integerish(1)]
number of lines to create.

vertices

[integerish(.)]
number of vertices per line; will be recycled if it does not have as many elements as specified in features.

...

[various]
graphical parameters to gt_locate, in case points are sketched; see gpar

Details

The argument anchor indicates how the geom is created:

Value

A geom.

See Also

Other geometry shapes: gs_point(), gs_polygon(), gs_random()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 1. create a line 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_line(anchor = coords))

# the vertices are plottet relative to the window
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
aLine <- gs_line(anchor = coords, window = window)
visualise(aLine, linecol = "green")

# when a geom is used in 'anchor', its properties are passed on
aGeom <- setWindow(x = aGeom, to = window)
aLine <- gs_line(anchor = aGeom)
visualise(aLine, linecol = "deeppink")

# 2. sketch a line
if(dev.interactive()){
  aLine <- gs_line(vertices = 4)
  visualise(aLine, linecol = "orange", linewidth = 5, new = FALSE)
}

geometr documentation built on Sept. 21, 2021, 1:07 a.m.