nasa-nccs-hpda / srlite

surface reflectance
0 stars 1 forks source link

Check if gdal_merge() can create COG directly w/out intermediate non-cog file [Software] #18

Closed gtamkin closed 2 months ago

gtamkin commented 2 months ago

To support user-selectable band pairs, we need to dynamically add simulated bands to the srlite GeoTIFF file as we process them. This ultimately requires the GeoTIFF driver, which means that the COG generation occurs after the initial GeoTIFF file is created. The second step is performed by gdalTranslate() API and cannot be shortcut by gdal_merge() programmatically.

Create new GeoTIFF raster - Can't use COG driver unless we use CreateCopy, which causes issues when we have less bands in SR than TOA

driver_GTiff = gdal.GetDriverByName('GTiff') ds_toa_copy_GTiff = driver_GTiff.Create(intermediate_output_name, xsize=ds_toa.RasterXSize, ysize=ds_toa.RasterYSize, bands=numBandPairs, eType=toa_datatype, options=['COMPRESS=LZW'])