View source: R/tar-terra-sprc.R
tar_terra_sprc | R Documentation |
Provides a target format for terra::SpatRasterCollection objects, which have no restriction in the extent or other geometric parameters.
tar_terra_sprc(
name,
command,
pattern = NULL,
filetype = geotargets_option_get("gdal.raster.driver"),
gdal = geotargets_option_get("gdal.raster.creation.options"),
...,
tidy_eval = targets::tar_option_get("tidy_eval"),
packages = targets::tar_option_get("packages"),
library = targets::tar_option_get("library"),
repository = targets::tar_option_get("repository"),
error = targets::tar_option_get("error"),
memory = targets::tar_option_get("memory"),
garbage_collection = targets::tar_option_get("garbage_collection"),
deployment = targets::tar_option_get("deployment"),
priority = targets::tar_option_get("priority"),
resources = targets::tar_option_get("resources"),
storage = targets::tar_option_get("storage"),
retrieval = targets::tar_option_get("retrieval"),
cue = targets::tar_option_get("cue"),
description = targets::tar_option_get("description")
)
name |
Symbol, name of the target. A target name must be a valid name
for a symbol in R, and it must not start with a dot. See
|
command |
R code to run the target. |
pattern |
Code to define a dynamic branching pattern for a target. See
|
filetype |
character. File format expressed as GDAL driver names passed
to |
gdal |
character. GDAL driver specific datasource creation options.
passed to |
... |
Additional arguments not yet used. |
tidy_eval |
Logical, whether to enable tidy evaluation
when interpreting |
packages |
Character vector of packages to load right before
the target runs or the output data is reloaded for
downstream targets. Use |
library |
Character vector of library paths to try
when loading |
repository |
Character of length 1, remote repository for target storage. Choices:
Note: if |
error |
Character of length 1, what to do if the target stops and throws an error. Options:
|
memory |
Character of length 1, memory strategy. Possible values:
For cloud-based file targets
(e.g. |
garbage_collection |
Logical: |
deployment |
Character of length 1. If |
priority |
Deprecated on 2025-04-08 ( |
resources |
Object returned by |
storage |
Character string to control when the output of the target
is saved to storage. Only relevant when using
|
retrieval |
Character string to control when the current target
loads its dependencies into memory before running.
(Here, a "dependency" is another target upstream that the current one
depends on.) Only relevant when using
|
cue |
An optional object from |
description |
Character of length 1, a custom free-form human-readable
text description of the target. Descriptions appear as target labels
in functions like |
The terra package uses objects like terra::SpatRaster,
terra::SpatVector, and terra::SpatRasterDataset (SDS), which do
not contain the data directly–they contain a C++ pointer to memory where
the data is stored. As a result, these objects are not portable between
R sessions without special handling, which causes problems when including
them in targets
pipelines with targets::tar_target()
. The functions,
tar_terra_rast()
, tar_terra_sds()
, tar_terra_sprc()
,
tar_terra_tiles()
, and tar_terra_vect()
handle this issue by writing and
reading the target as a geospatial file (specified by filetype
) rather
than saving the relevant object (e.g., SpatRaster
, SpatVector
, etc.),
itself.
target class "tar_stem" for use in a target pipeline
The iteration
argument is unavailable because it is hard-coded to
"list"
, the only option that works currently.
Andrew Gene Brown
Nicholas Tierney
targets::tar_target_raw()
# For CRAN. Ensures these examples run under certain conditions.
# To run this locally, run the code inside this if statement
if (Sys.getenv("TAR_LONG_EXAMPLES") == "true") {
targets::tar_dir({ # tar_dir() runs code from a temporary directory.
targets::tar_script({
library(geotargets)
elev_scale <- function(z = 1, projection = "EPSG:4326") {
terra::project(
terra::rast(system.file("ex", "elev.tif", package = "terra")) * z,
projection
)
}
list(
tar_terra_sprc(
raster_elevs,
# two rasters, one unaltered, one scaled by factor of 2 and
# reprojected to interrupted good homolosine
command = terra::sprc(list(
elev_scale(1),
elev_scale(2, "+proj=igh")
))
)
)
})
targets::tar_make()
targets::tar_read(raster_elevs)
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.