createCopy | R Documentation |
createCopy()
copies a raster dataset, optionally changing the format.
The extent, cell size, number of bands, data type, projection, and
geotransform are all copied from the source raster.
createCopy(
format,
dst_filename,
src_filename,
strict = FALSE,
options = NULL,
quiet = FALSE,
return_obj = FALSE
)
format |
Character string giving the format short name for the
output raster (e.g., |
dst_filename |
Character string giving the filename to create. |
src_filename |
Either a character string giving the filename of the
source raster, or object of class |
strict |
Logical. |
options |
Optional list of format-specific creation options in a
vector of |
quiet |
Logical scalar. If |
return_obj |
Logical scalar. If |
By default, returns a logical value indicating success (invisible
TRUE
, output written to dst_filename
). An error is raised if the
operation fails. An object of class GDALRaster
open on the
output dataset will be returned if return_obj = TRUE
.
dst_filename
may be an empty string (""
) with format = "MEM"
and
return_obj = TRUE
to create an In-memory Raster
(https://gdal.org/en/stable/drivers/raster/mem.html).
GDALRaster-class
, create()
, getCreationOptions()
,
rasterFromRaster()
, translate()
lcp_file <- system.file("extdata/storm_lake.lcp", package="gdalraster")
tif_file <- file.path(tempdir(), "storml_lndscp.tif")
ds <- createCopy(format = "GTiff",
dst_filename = tif_file,
src_filename = lcp_file,
options = "COMPRESS=LZW",
return_obj = TRUE)
ds$getMetadata(band = 0, domain = "IMAGE_STRUCTURE")
for (band in 1:ds$getRasterCount())
ds$setNoDataValue(band, -9999)
ds$getStatistics(band = 1, approx_ok = FALSE, force = TRUE)
ds$close()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.