Open wildintellect opened 3 years ago
Code will look something like
print(paste0("Write tmp tif: ", out_tif_fn))
tifoptions <- c("COMPRESS=DEFLATE", "PREDICTOR=2", "ZLEVEL=6")
writeRaster(out_stack, filename=out_tif_fn, format="GTiff", datatype="FLT4S", overwrite=TRUE, options=tifoptions)
print(paste0("Write COG tif: ", out_cog_fn))
#rio cogeo create --overview-level=5 {input} {output}
system2(command = "rio",
args = c("cogeo", "create", "--overview-level=5", out_tif_fn, out_cog_fn),
stdout = TRUE,
stderr = TRUE,
wait = TRUE
)
file.remove(out_tif_fn)
In working on Boreal-wide visualization of the dps_outputs I discovered a few things we missed while making the COGs at various steps.
In the case of AGB outputs we can replace
gdal_translate
withrio cogeo create --overview-level=5 {input} {output}
which will solve both the issue of compression and overviews.@lauraduncanson @pahbs @nmt28 , for the F2F and COP26 I'll probably end up creating a copy of the existing data with these settings applied. For AGB it's going to shrink the files from 200mb to 82mb, and hopefully improve rendering time (3-4s per file to .5s). We should update the code for future runs to output optimized files, and add to the MAAP documentation.