bandCopyWholeRaster {gdalraster} | R Documentation |
Copy a whole raster band efficiently
Description
bandCopyWholeRaster()
copies the complete raster contents of one band to
another similarly configured band. The source and destination bands must
have the same xsize and ysize. The bands do not have to have the same data
type. It implements efficient copying, in particular "chunking" the copy in
substantial blocks. This is a wrapper for GDALRasterBandCopyWholeRaster()
in the GDAL API.
Usage
bandCopyWholeRaster(
src_filename,
src_band,
dst_filename,
dst_band,
options = NULL,
quiet = FALSE
)
Arguments
src_filename |
Filename of the source raster. |
src_band |
Band number in the source raster to be copied. |
dst_filename |
Filename of the destination raster. |
dst_band |
Band number in the destination raster to copy into. |
options |
Optional list of transfer hints in a vector of
|
quiet |
Logical scalar. If |
Value
Logical indicating success (invisible TRUE
).
An error is raised if the operation fails.
See Also
GDALRaster-class
, create()
, createCopy()
,
rasterFromRaster()
Examples
## copy Landsat data from a single-band file to a new multi-band image
b5_file <- system.file("extdata/sr_b5_20200829.tif", package="gdalraster")
dst_file <- file.path(tempdir(), "sr_multi.tif")
rasterFromRaster(b5_file, dst_file, nbands=7, init=0)
opt <- c("COMPRESSED=YES", "SKIP_HOLES=YES")
bandCopyWholeRaster(b5_file, 1, dst_file, 5, options=opt)
ds <- new(GDALRaster, dst_file)
ds$getStatistics(band=5, approx_ok=FALSE, force=TRUE)
ds$close()
deleteDataset(dst_file)