Provides an abbreviated version of the well-known text representation of a geometry. This returns a constant number of coordinates for each geometry, so is safe to use for geometry vectors with many (potentially large) features. Parse errors are passed on to the format string and do not cause this handler to error.

wk_format(handleable, precision = 7, trim = TRUE, max_coords = 6, ...)

wkt_format_handler(precision = 7, trim = TRUE, max_coords = 6)

Arguments

handleable

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

precision

If trim is TRUE, the total number of significant digits to keep for each result or the number of digits after the decimal place otherwise.

trim

Use FALSE to keep trailing zeroes after the decimal place.

max_coords

The maximum number of coordinates to include in the output.

...

Passed to the wk_handle() method.

Value

A character vector of abbreviated well-known text.

Examples

wk_format(wkt("MULTIPOLYGON (((0 0, 10 0, 0 10, 0 0)))"))
#> [1] "MULTIPOLYGON (((0 0, 10 0, 0 10, 0 0)))"
wk_format(new_wk_wkt("POINT ENTPY"))
#> [1] "POINT (!!! Expected '(' or 'EMPTY' but found 'ENTPY' at byte 6"
wk_handle(
  wkt("MULTIPOLYGON (((0 0, 10 0, 0 10, 0 0)))"),
  wkt_format_handler()
)
#> [1] "MULTIPOLYGON (((0 0, 10 0, 0 10, 0 0)))"