View source: R/stack_rasters.R
stack_rasters | R Documentation |
This function creates an output raster that "stacks" all the bands of its input rasters, as though they were loaded one after another into a GIS. It does this by first constructing a GDAL virtual raster, or "VRT", and then optionally uses GDAL's warper to convert this VRT into a standalone file. The VRT is fast to create and does not require much space, but does require the input rasters not be moved or altered. Creating a standalone raster from this file may take a long time and a large amount of disk space.
stack_rasters(
rasters,
output_filename,
...,
resolution,
extent,
reference_raster = 1,
resampling_method = "bilinear",
band_names,
check_crs = TRUE,
gdalwarp_options = c("-multi", "-overwrite", "-co", "COMPRESS=DEFLATE", "-co",
"PREDICTOR=2", "-co", "NUM_THREADS=ALL_CPUS"),
gdal_config_options = c(VSI_CACHE = "TRUE", GDAL_CACHEMAX = "30%", VSI_CACHE_SIZE =
"10000000", GDAL_HTTP_MULTIPLEX = "YES", GDAL_INGESTED_BYTES_AT_OPEN = "32000",
GDAL_DISABLE_READDIR_ON_OPEN = "EMPTY_DIR", GDAL_HTTP_VERSION = "2",
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES = "YES", GDAL_NUM_THREADS = "ALL_CPUS")
)
rasters |
A list of rasters to combine into a single multi-band raster,
as character file paths to files that can be read by |
output_filename |
The location to save the final "stacked" raster. If
this filename has a "vrt" extension as determined by |
... |
These dots are for future extensions and must be empty. |
resolution |
Numeric of length 2, representing the target X and Y resolution of the output raster. If only a single value is provided, it will be used for both X and Y resolution; if more than 2 values are provided, an error is thrown. |
extent |
Numeric of length 4, representing the target xmin, ymin, xmax, and ymax values of the output raster (its bounding box), in that order. |
reference_raster |
The position (index) of the raster in |
resampling_method |
The method to use when resampling to different resolutions in the VRT. |
band_names |
Either a character vector of band names, or a function that when given a character vector of band names, returns a character vector of the same length containing new band names. |
check_crs |
Logical: Should this function check that all |
gdalwarp_options |
Options passed to |
gdal_config_options |
Options passed to |
output_filename
, unchanged.
stack_rasters(
list(
system.file("rasters/dpdd.tif", package = "rsi"),
system.file("rasters/example_sentinel1.tif", package = "rsi")
),
tempfile(fileext = ".vrt")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.