Read and write well-known text

geos_read_wkt(wkt, fix_structure = FALSE, crs = NULL)

geos_write_wkt(geom, include_z = TRUE, precision = 16, trim = TRUE)

geos_read_geojson(geojson, crs = NULL)

geos_write_geojson(geom, indent = -1)

geos_read_wkb(wkb, fix_structure = FALSE, crs = NULL)

geos_write_wkb(
  geom,
  include_z = TRUE,
  include_srid = FALSE,
  endian = 1,
  flavor = c("extended", "iso")
)

geos_read_hex(hex, fix_structure = FALSE, crs = NULL)

geos_write_hex(
  geom,
  include_z = TRUE,
  include_srid = FALSE,
  endian = 1,
  flavor = c("extended", "iso")
)

geos_read_xy(point)

geos_write_xy(geom)

Arguments

wkt

a character() vector of well-known text

fix_structure

Set the reader to automatically repair structural errors in the input (currently just unclosed rings) while reading.

crs

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

geom

A GEOS geometry vector

include_z, include_srid

Include the values of the Z and M coordinates and/or SRID in the output? Use FALSE to omit, TRUE to include, or NA to include only if present. Note that using TRUE may result in an error if there is no value present in the original.

precision

The number of significant digits to include iin WKT output.

trim

Trim unnecessary zeroes in the output?

geojson

A character() vector fo GeoJSON features

indent

The number of spaces to use when indenting a formatted version of the output. Use -1 to indicate no formatting.

wkb

A list() of raw() vectors (or NULL representing an NA value).

endian

0 for big endian or 1 for little endian.

flavor

One of "extended" (i.e., EWKB) or "iso".

hex

A hexidecimal representation of well-known binary

point

A list() representing points in the form list(x, y).

Examples

geos_read_wkt("POINT (30 10)")
#> <geos_geometry[1]>
#> [1] <POINT (30 10)>
geos_write_wkt(geos_read_wkt("POINT (30 10)"))
#> [1] "POINT (30 10)"