geo_point: Create or cast to a point 'geom'

View source: R/geo_point.R

geo_pointR Documentation

Create or cast to a point geom

Description

Create a point geometry (of class geom) either programatically by specifying coordinate values, by sketching it or by casting to it from another geom type.

Usage

geo_point(crds = NULL, window = NULL, vertices = 1)

as_point(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.

vertices

integerish(1)
if neither crds nor window are given, this indicates how often you can click into a plot to determine the location of the coordinates manually.

geom

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

Value

A point geom.

See Also

Other geometry shapes: geo_line(), geo_polygon(), geo_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 ...
(pointGeom <- geo_point(crds = coords))

# ... otherwise the vertices are plotted relative to the window
window <- data.frame(x = c(0, 80),
                     y = c(0, 80))
points <- geo_point(crds = coords, window = window)

geo_vis(points, linecol = "#FFB000")

# 2. cast to point geom from another type
pointGeom <- as_point(geom = gtGeoms$polygon)

geo_vis(gtGeoms$polygon, linecol = "#FFB000", theme = setTheme(box = list(fillcol = "#282828")))
geo_vis(pointGeom, linecol = "#33FF00", pointsymbol = 5, new = FALSE)

# 3. sketch two points
if(dev.interactive()){
  points <- geo_point(vertices = 2)
  geo_vis(points, linecol = "#B24223", pointsymbol = 22, new = FALSE)
}

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