Learn R Programming

geometr (version 0.2.5)

gt_sketch: Sketch geoms

Description

Sketch geoms by clicking into a plot.

Usage

gt_sketch(
  template = NULL,
  shape = NULL,
  features = 1,
  vertices = NULL,
  regular = FALSE,
  fixed = FALSE,
  show = FALSE,
  ...
)

Arguments

template

[RasterLayer(1) | matrix(1)] Gridded object that serves as template to sketch the geometry.

shape

[character(1)] a geometry shape that should be sketched, possible are the geom types "point", "line" and "polygon" and special cases thereof (recently implemented are "triangle", "square", "hexagon") and "random".

features

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

vertices

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

regular

[logical(1)] if a polygon is sketched, should it be regular, i.e. point symmetric (TRUE) with the number of corners defined by vertices or should the vertices be selected according to the click locations, resulting in a non-regular polygon (FALSE, default)?

fixed

[logical(1)] if a regular polygon is sketched, should it be aligned vertically (TRUE, default), or should it be aligned according to the second click (FALSE); only relevant if regular = TRUE.

show

[logical(1)] should plot information be shown in the plot (TRUE), or should the geom merely be returned in the console (FALSE, default)

...

[various] additional arguments to gt_locate.

Value

An invisible geom.

See Also

Other geometry tools: gt_reflect(), gt_rotate(), gt_scale(), gt_skew(), gt_stretch(), gt_translate()

Examples

Run this code
# NOT RUN {
# sketch a point geometry
gt_sketch(template = gtRasters$categorical, shape = "point") %>%
  visualise(points = ., linecol = "green", pointsymbol = 5, new = FALSE)

# sketch a line geometry
gt_sketch(template = gtRasters$categorical, vertices = 4, shape = "line") %>%
  visualise(points = ., linecol = "orange", linewidth = 5, new = FALSE)

# sketch a polygon geometry
gt_sketch(template = gtRasters$continuous, shape = "hexagon") %>%
  visualise(geom = ., linecol = "deeppink", linetype = 2, new = FALSE)
# }

Run the code above in your browser using DataLab