geo_line: Create a line 'geom'

View source: R/geo_line.R

geo_lineR Documentation

Create a line geom

Description

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

Usage

geo_line(crds = NULL, window = NULL, features = 1, vertices = 2)

as_line(geom)

Arguments

crds

data.frame(2)
Coordinates to build the geom from. It must include the column names x and y.

window

data.frame(2)
in case the reference window deviates from the bounding box of crds, specify here the minimum and maximum values in columns x and y.

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.

geom

gridded(1)
the geom to cast to type 'line'.

Value

A line geom.

See Also

Other geometry shapes: geo_point(), geo_polygon(), geo_random()

Examples

# 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
(lineGeom <- geo_line(crds = coords))

# ... otherwise the vertices are plotted relative to the window

# the vertices are plottet relative to the window
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
lineGeom <- geo_line(crds = coords, window = window)

geo_vis(lineGeom, linecol = "green")

# 2. cast to point geom from another type
lineGeom <- as_line(geom = gtGeoms$point)

geo_vis(gtGeoms$point, linecol = "#FFB000", pointsymbol = 5)
geo_vis(lineGeom, linecol = "#33FF00", new = FALSE)

# 3. sketch a line
if(dev.interactive()){
  line <- geo_line(vertices = 4)
  geo_vis(line, linecol = "#B24223", linewidth = 5, new = FALSE)
}

EhrmannS/geometr documentation built on Jan. 31, 2024, 9:13 a.m.