These functions provide ways to extract individual coordinate values. Whereas wk_vertices() returns a vector of coordinates as in the same format as the input, wk_coords() returns a data frame with coordinates as columns.

wk_vertices(handleable, ...)

wk_coords(handleable, ...)

wk_vertex_filter(handler, add_details = FALSE)

Arguments

handleable

A geometry vector (e.g., wkb(), wkt(), xy(), rct(), or sf::st_sfc()) for which wk_handle() is defined.

...

Passed to the wk_handle() method.

handler

A wk_handler object.

add_details

Use TRUE to add a "wk_details" attribute, which contains columns feature_id, part_id, and ring_id.

Value

  • wk_vertices() extracts vertices and returns the in the same format as the handler

  • wk_coords() returns a data frame with columns columns feature_id (the index of the feature from whence it came), part_id (an arbitrary integer identifying the point, line, or polygon from whence it came), ring_id (an arbitrary integer identifying individual rings within polygons), and one column per coordinate (x, y, and/or z and/or m).

Examples

wk_vertices(wkt("LINESTRING (0 0, 1 1)"))
#> <wk_wkt[2]> #> [1] POINT (0 0) POINT (1 1)
wk_coords(wkt("LINESTRING (0 0, 1 1)"))
#> feature_id part_id ring_id x y #> 1 1 1 0 0 0 #> 2 1 1 0 1 1