Whereas the wk package provides headers and class definitions for well-known geometry formats, this package uses those headers to interrogate and transform these vectors.
You can install the released version of wkutils from CRAN with:
And the development version from GitHub with:
The gist of the functions in this package:
library(wkutils)
wkt_coords("POINT (30 10)")
#> # A tibble: 1 x 7
#> feature_id part_id ring_id x y z m
#> <int> <int> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 0 30 10 NA NA
coords_point_translate_wkt(30, 10)
#> [1] "POINT (30 10)"
wkt_debug("POINT (30 10)")
#> nextFeatureStart(0)
#> nextGeometryStart(POINT [1], WKReader::PART_ID_NONE)
#> nextCoordinate(POINT [1], WKCoord(x = 30, y = 10), 0)
#> nextGeometryEnd(POINT [1], WKReader::PART_ID_NONE)
#> nextFeatureEnd(0)
wkt_set_srid("POINT (30 10)", 1234)
#> [1] "SRID=1234;POINT (30 10)"
wkt_set_z("POINT (30 10)", 1234)
#> [1] "POINT Z (30 10 1234)"
wkt_meta("POINT (30 10)")
#> # A tibble: 1 x 7
#> feature_id part_id type_id size srid has_z has_m
#> <int> <int> <int> <int> <int> <lgl> <lgl>
#> 1 1 1 1 1 NA FALSE FALSE
wkt_ranges("POINT (30 10)")
#> # A tibble: 1 x 8
#> xmin ymin zmin mmin xmax ymax zmax mmax
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 30 10 Inf Inf 30 10 -Inf -Inf
The package also contains plot methods for wk::wkb()
and wk::wkt()
vectors. These aren’t intended to be high-performance, but are helpful for debugging geometries.
Finally, the package contains slightly faster functions to send points, lines, and polygons to a graphics device: