Closed bojanbizjak closed 11 months ago
It is certainly possible, but it would require adding libgeotiff
as a dependency on all OSes
You can use this to convert to COG manually
const filePath = '/tmp/nonCog.tiff',
const resultFilePath = '/tmp/cog.tiff'
const temporaryFilePath = '/tmp/temporary.tiff'
const dataset = await gdal.openAsync(filePath);
const tiled = await gdal.translateAsync(temporaryFilePath, dataset, ['-co', 'TILED=YES', '-co', 'COMPRESS=DEFLATE']);
await tiled.buildOverviewsAsync('NEAREST', [2, 4, 8, 16, 32]);
await gdal.translateAsync(resultFilePath, tiled, ['-co', 'TILED=YES', '-co', 'COMPRESS=DEFLATE', '-co', 'COPY_SRC_OVERVIEWS=YES']);
It seems that in recent GDAL versions, the internal libtiff
supports COG out of the box, everything that is needed is to add proper files for unit testing to render it official
I confirm, converting files to COG is supported out of the box:
In Node.js:
const cog = gdal.drivers.get('COG');
cog.createCopy('sample-cog.tif', gdal.open('sample.tif'));
Then on the command-line:
python ./node_modules/gdal-async/deps/libgdal/gdal/swig/python/gdal-utils/osgeo_utils/samples/validate_cloud_optimized_geotiff.py sample-cog.tif
sample-cog.tif is a valid cloud optimized GeoTIFF
The size of all IFD headers is 1096 bytes
I remind you that the COG driver can be used only for writing. COGs are valid GeoTIFFs and can and must be read with the GeoTIFF driver.
I wonder if it is possible or planned to have built-in support for GeoTIFF to COG conversion?
Reference: COG – Cloud Optimized GeoTIFF generator - https://gdal.org/drivers/raster/cog.html