Learn R Programming

whitebox (version 2.4.3)

wbt_source: Initialize an R object containing spatial data for use by WhiteboxTools

Description

Initialize an R object containing spatial data for use by WhiteboxTools

Usage

wbt_source(
  x,
  dsn = NULL,
  layer = NULL,
  force = FALSE,
  tmpdir = tempdir(),
  pattern = "wbt",
  verbose = wbt_verbose(),
  ...
)

Value

An R object (SpatRaster, SpatVector, SpatVectorProxy, sf) with attributes wbt_dsn and wbt_layer set as needed to support reading and writing R objects from file by WhiteboxTools.

Arguments

x

A terra SpatVector or sf object (in memory) or a path to a file that can be read as a SpatVectorProxy. Or a memory or file-based SpatRaster. When x has multiple layers/bands, the first layer is used by default; use the layer argument to select a specific layer/band.

dsn

Data source path / file name

layer

Data layer. For vectors, layer is interpreted as a layer name (character); for rasters, layer is interpreted as a band index or name (integer OR character)

force

Force write of vector data to file? Default: FALSE (only write if file does not exist and new file is needed)

tmpdir

Directory to write temporary ESRI Shapefiles for vector input in memory or otherwise not already in shapefile. Default: tempdir()

pattern

Character vector giving the initial part of the temporary file name

verbose

Print information about data source and contents?

...

Additional arguments passed to terra::writeVector() or sf::st_write(), or terra::writeRaster (for rasters).