Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gs_point

Create a point geom


Description

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

Usage

gs_point(anchor = NULL, window = NULL, vertices = 1, ...)

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.

vertices

[integer(1)]
number of vertices.

...

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

Details

The argument anchor indicates how the geom is created:

  • if anchor is set, the geom is created parametrically from the points given in anchor,

  • if it is not set either window or a default window between 0 and 1 is opened to sketch the geom.

Value

A geom.

See Also

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

Examples

# 1. create points 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_point(anchor = coords))

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

# when a geom is used in 'anchor', its properties are passed on
aGeom <- setWindow(x = aGeom, to = window)
points <- gs_point(anchor = aGeom)
visualise(points)

# 2. sketch two points
if(dev.interactive()){
  points <- gs_point(vertices = 2)
  visualise(points, linecol = "green", pointsymbol = 5, new = FALSE)
}

geometr

Generate and Modify Interoperable Geometric Shapes

v0.2.10
GPL-3
Authors
Steffen Ehrmann [aut, cre] (<https://orcid.org/0000-0002-2958-0796>), Dan Sunday [cph] (fast point-in-polygon algorithm.)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.