Efficient point vectors

xy(x = double(), y = double(), crs = wk_crs_auto())

xyz(x = double(), y = double(), z = double(), crs = wk_crs_auto())

xym(x = double(), y = double(), m = double(), crs = wk_crs_auto())

xyzm(
  x = double(),
  y = double(),
  z = double(),
  m = double(),
  crs = wk_crs_auto()
)

xy_dims(x)

as_xy(x, ...)

# S3 method for default
as_xy(x, ..., dims = NULL)

# S3 method for wk_xy
as_xy(x, ..., dims = NULL)

# S3 method for matrix
as_xy(x, ..., crs = NULL)

# S3 method for data.frame
as_xy(x, ..., dims = NULL, crs = NULL)

Arguments

x, y, z, m

Coordinate values.

crs

A value to be propagated as the CRS for this vector.

...

Passed to methods.

dims

A set containing one or more of c("x", "y", "z", "m").

Value

A vector of coordinate values.

Examples

xy(1:5, 1:5)
#> <wk_xy[5]>
#> [1] (1 1) (2 2) (3 3) (4 4) (5 5)
xyz(1:5, 1:5, 10)
#> <wk_xyz[5]>
#> [1] Z (1 1 10) Z (2 2 10) Z (3 3 10) Z (4 4 10) Z (5 5 10)
xym(1:5, 1:5, 10)
#> <wk_xym[5]>
#> [1] M (1 1 10) M (2 2 10) M (3 3 10) M (4 4 10) M (5 5 10)
xyzm(1:5, 1:5, 10, 12)
#> <wk_xyzm[5]>
#> [1] ZM (1 1 10 12) ZM (2 2 10 12) ZM (3 3 10 12) ZM (4 4 10 12) ZM (5 5 10 12)

# NA, NA maps to a null/na feature; NaN, NaN maps to EMPTY
as_wkt(xy(NaN, NaN))
#> <wk_wkt[1]>
#> [1] POINT EMPTY
as_wkt(xy(NA, NA))
#> <wk_wkt[1]>
#> [1] <null feature>