<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.Shkpostityyli18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Maybe the band list be zero based? Try [0,1,2].<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<b>Puolesta </b>Nicole Kamp<br>
<b>Lähetetty:</b> torstai 25. marraskuuta 2021 14.44<br>
<b>Vastaanottaja:</b> gdal-dev@lists.osgeo.org<br>
<b>Aihe:</b> [gdal-dev] GDAL COG - Problem with Overviews<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Dear GDAL Developers, <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">I have an overview problem with my Cloud Optimized GeoTIFF.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I tried to translate a 16 bit, 4 bands ortho image to a COG 8bit, 3 bands image with JPEG compression.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://pasteboard.co/CLur6VdD0CwQ.jpg">That is the original image.</a><br>
<a href="https://pasteboard.co/MJv3lOjlI8iM.jpg">That is the result.</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">It works fine with LZW compression, but I need the JPEG compression. What am I doing wrong?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks, <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Niki<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here is my code.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:7.5pt;font-family:"Times New Roman",serif"> for raster in glob.glob(str(parameters[self.INPUT_Pfad])+'/*.tif'):<br>
fileInfo = QFileInfo(raster)<br>
baseName = fileInfo.baseName()<br>
file_name = str(parameters[self.INPUT_Pfad])+'/'+baseName+'.tif'<br>
feedback.pushInfo(file_name)<br>
output_file1 = str(parameters[self.OUTPUT_Pfad])+'/'+baseName+'.tif'<br>
output_file2 = str(parameters[self.OUTPUT_Pfad])+'/'+baseName+'_cog.tif'<br>
<br>
# Create COG<br>
x_size = 6250<br>
y_size = 5000<br>
num_bands = 4<br>
<br>
src_ds = gdal.Open(file_name)<br>
format = "GTiff"<br>
driver = gdal.GetDriverByName(format)<br>
<br>
# Translate<br>
translate_options = gdal.TranslateOptions(format = 'COG', outputType = gdal.GDT_Byte, bandList = [1,2,3], scaleParams=[''],<br>
creationOptions = ['TILED=YES','COMPRESS=JPEG','BIGTIFF=IF_NEEDED', 'BLOCKXSIZE=512', 'BLOCKYSIZE=512', 'RESAMPLING=NEAREST',
'OVERVIEWS=IGNORE_EXISTING', 'INTERLEAVE=PIXEL']<br>
)<br>
gdal.Translate(output_file1, src_ds, options=translate_options)<br>
<br>
translate_options = None<br>
src_ds = None</span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>