[gdal-dev] GDAL COG - Problem with Overviews

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Thu Nov 25 04:49:13 PST 2021


Hi,

Maybe the band list be zero based? Try [0,1,2].

-Jukka Rahkonen-

Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Nicole Kamp
Lähetetty: torstai 25. marraskuuta 2021 14.44
Vastaanottaja: gdal-dev at lists.osgeo.org
Aihe: [gdal-dev] GDAL COG - Problem with Overviews

Dear GDAL Developers,
I have an overview problem with my Cloud Optimized GeoTIFF.
I tried to translate a 16 bit, 4 bands ortho image to a COG 8bit, 3 bands image with JPEG compression.

That is the original image.<https://pasteboard.co/CLur6VdD0CwQ.jpg>
That is the result.<https://pasteboard.co/MJv3lOjlI8iM.jpg>

It works fine with LZW compression, but I need the JPEG compression. What am I doing wrong?

Thanks,
Niki


Here is my code.
        for raster in glob.glob(str(parameters[self.INPUT_Pfad])+'/*.tif'):
            fileInfo = QFileInfo(raster)
            baseName = fileInfo.baseName()
            file_name = str(parameters[self.INPUT_Pfad])+'/'+baseName+'.tif'
            feedback.pushInfo(file_name)
            output_file1 = str(parameters[self.OUTPUT_Pfad])+'/'+baseName+'.tif'
            output_file2 = str(parameters[self.OUTPUT_Pfad])+'/'+baseName+'_cog.tif'

            # Create COG
            x_size = 6250
            y_size = 5000
            num_bands = 4

            src_ds = gdal.Open(file_name)
            format = "GTiff"
            driver = gdal.GetDriverByName(format)

            # Translate
            translate_options = gdal.TranslateOptions(format = 'COG', outputType = gdal.GDT_Byte, bandList =                                                     [1,2,3],  scaleParams=[''],
                                          creationOptions = ['TILED=YES','COMPRESS=JPEG','BIGTIFF=IF_NEEDED',                                                      'BLOCKXSIZE=512', 'BLOCKYSIZE=512', 'RESAMPLING=NEAREST',                                                                'OVERVIEWS=IGNORE_EXISTING', 'INTERLEAVE=PIXEL']
                                          )
            gdal.Translate(output_file1, src_ds, options=translate_options)

            translate_options = None
            src_ds = None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211125/4f94ec61/attachment.html>


More information about the gdal-dev mailing list