| translate_cog {gdalcubes} | R Documentation |
This function translates all images of a gdalcubes image collection to cloud-optimized GeoTIFF files. The output contains converted imagery as an additional copy (original files are not deleted) and a new image collection file.
translate_cog(
collection,
target_dir = tempfile(pattern = "image_collection_"),
overwrite = TRUE,
creation_options = c("BLOCKSIZE=256", "COMPRESS=DEFLTE", "LEVEL=1",
"RESAMPLING=CUBIC")
)
collection |
path to an existing image collection file |
target_dir |
directory where the output will be stored, will be created if necessary |
overwrite |
logical; if TRUE existing files will be overwritten |
creation_options |
further settings of the GDAL COG driver; see https://gdal.org/drivers/raster/cog.html |
path to the new image collection file for use as argument to image_collection
This function requires the GDAL COG driver, which was added in GDAL version 3.1.
# create image collection from example Landsat data only
# if not already done in other examples
if (!file.exists(file.path(tempdir(), "L8.db"))) {
L8_files <- list.files(system.file("L8NY18", package = "gdalcubes"),
".TIF", recursive = TRUE, full.names = TRUE)
create_image_collection(L8_files, "L8_L1TP", file.path(tempdir(), "L8.db"))
}
L8.col = image_collection(file.path(tempdir(), "L8.db"))
L8.col
if ("COG" %in% gdalcubes_gdalformats()) {
L8.cog.col = translate_cog(L8.col)
L8.cog.col
}