These functions transform raw coordinates into point, line, polygon, features, or nest a vector of geometries into a MULTI* type or GEOMETRYCOLLECTION. See wk::wk_coords(), geos_unnest(), or wk::wk_flatten() to perform inverse operations; see wk::xy(), wk::wk_linestring(), wk::wk_polygon(), or wk::wk_collection() for generic versions that work with non-GEOS types.

geos_make_point(x, y, z = NA_real_, crs = NULL)

geos_make_linestring(x, y, z = NA_real_, feature_id = 1L, crs = NULL)

geos_make_polygon(
  x,
  y,
  z = NA_real_,
  feature_id = 1L,
  ring_id = 1L,
  crs = NULL
)

geos_make_collection(geom, type_id = "geometrycollection", feature_id = 1L)

Arguments

x, y, z

Vectors of coordinate values

crs

An object that can be interpreted as a CRS. See wk::wk_crs().

feature_id, ring_id

Vectors for which a change in sequential values indicates a new feature or ring. Use factor() to convert from a character vector.

geom

A GEOS geometry vector

type_id

The numeric type identifier for which an empty should be returned, an object from which one can be extracted using as_geos_type_id() (default to calling geos_type_id()). This is most usefully a character vector with the geometry type (e.g., point, linestring, polygon).

Examples

geos_make_point(1:3, 1:3)
#> <geos_geometry[3]>
#> [1] <POINT (1 1)> <POINT (2 2)> <POINT (3 3)>
geos_make_linestring(1:3, 1:3)
#> <geos_geometry[1]>
#> [1] <LINESTRING (1 1, 2 2, 3 3)>
geos_make_polygon(c(0, 1, 0), c(0, 0, 1))
#> <geos_geometry[1]>
#> [1] <POLYGON ((0 0, 1 0, 0 1, 0 0))>
geos_make_collection("POINT (1 1)")
#> <geos_geometry[1]>
#> [1] <GEOMETRYCOLLECTION (POINT (1 1))>