Converts various Whitebox objects to vectors:
For WhiteboxRaster: converts raster values to a vector in row-major order
For WhiteboxExtent: converts extent boundaries to a named vector
Usage
# S4 method for class 'WhiteboxRaster'
as_vector(x, raw = FALSE)
# S4 method for class 'WhiteboxExtent'
as_vector(x)
Arguments
- x
Object to convert to vector. Can be:
A WhiteboxRaster object
A WhiteboxExtent object
- raw
logical. For WhiteboxRaster only: Should the raw data be returned (
raw = TRUE
) or should NoData values be transformed toNA
(raw = FALSE
)?
Value
A vector, with type depending on the input:
For WhiteboxRaster: vector containing raster values
For WhiteboxExtent: named vector containing extent values
Examples
f <- system.file("extdata/dem.tif", package = "wbw")
x <- wbw_read_raster(f)
# Return WhiteboxRaster's data:
head(as_vector(x))
#> [1] 115.4213 112.8404 109.7914 106.8473 105.0610 103.1640
# Return WhiteboxExtent's data:
as_vector(wbw_ext(x))
#> west east south north
#> 1925449 1929446 5582091 5585717