wkb: Convert WKT to WKB

wkbR Documentation

Convert WKT to WKB

Description

Convert WKT to WKB

Usage

wkt_wkb(x, ...)

wkb_wkt(x, ...)

Arguments

x

For wkt_wkb(), a character string representing a WKT object; for wkb_wkt(), an of class raw representing a WKB object

...

arguments passed on to wk::wkt_translate_wkb() or wk::wkb_translate_wkt()

Value

wkt_wkb returns an object of class raw, a WKB reprsentation. wkb_wkt returns an object of class character, a WKT representation

Examples

# WKT to WKB
## point
wkt_wkb("POINT (-116.4 45.2)")

## linestring
wkt_wkb("LINESTRING (-116.4 45.2, -118.0 47.0)")

## multipoint
### only accepts the below format, not e.g., ((1 2), (3 4))
wkt_wkb("MULTIPOINT (100.000 3.101, 101.00 2.10, 3.14 2.18)")

## polygon
wkt_wkb("POLYGON ((100.0 0.0, 101.1 0.0, 101.0 1.0, 100.0 0.0))")

# WKB to WKT
## point
(x <- wkt_wkb("POINT (-116.4 45.2)"))
wkb_wkt(x)

## linestring
(x <- wkt_wkb("LINESTRING (-116.4 45.2, -118.0 47.0)"))
wkb_wkt(x)

## multipoint
(x <- wkt_wkb("MULTIPOINT (100.000 3.101, 101.00 2.10, 3.14 2.18)"))
wkb_wkt(x)

## polygon
(x <- wkt_wkb("POLYGON ((100.0 0.0, 101.1 0.0, 101.0 1.0, 100.0 0.0))"))
wkb_wkt(x)

ropensci/wellknown documentation built on April 8, 2023, 11:54 p.m.