b5_file <- system.file("extdata/sr_b5_20200829.tif", package="gdalraster")
b5_tmp <- file.path(tempdir(), "b5_tmp.tif")
file.copy(b5_file, b5_tmp)
ds <- new(GDALRaster, b5_tmp)
ds$buildOverviews("BILINEAR", levels = c(2, 4, 8), bands = c(1))
ds$getFileList()
ds$close()
b5_tmp2 <- file.path(tempdir(), "b5_tmp_renamed.tif")
renameDataset(b5_tmp2, b5_tmp)
ds <- new(GDALRaster, b5_tmp2)
ds$getFileList()
ds$close()
deleteDataset(b5_tmp2)
Run the code above in your browser using DataLab