<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=iso-8859-1">
<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;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 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:#0563C1;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
span.Shkpostityyli20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@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="#0563C1" vlink="#954F72" 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">I had a try by creating a 6-bit COG<br>
gdal_translate -of cog -co nbits=6 P4433H.tif 6bit.tif<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">tiffinfo shows:<br>
TIFF Directory at offset 0xc0 (192)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> Image Width: 12000 Image Length: 12000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> Tile Width: 512 Tile Length: 512<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> Resolution: 0.393677, 0.393677 pixels/cm<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"> Bits/Sample: 6<br>
<br>
but the MinSampleValue and MaxSampleValue tags are not set. In <a href="https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf">
https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf</a> MaxSampleValue is defined this way:<br>
</span><span lang="EN-US">MaxSampleValue The maximum component value used. Tag = 281 (119.H) Type = SHORT N = SamplesPerPixel This field is not to be used to affect the visual appearance of an image when it is displayed or printed. Nor should this field affect
the interpretation of any other field; it is used only for statistical purposes.
</span>Default is 2**(BitsPerSample) – 1<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">Thus, the MaxSampleValue in the test image is 63. The default for MinSampleValue is 0. The values may not tell the min/max values of the image data but fortunately
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL has its own way for saving the image statistics with more details. Image statistics are copied if they exist in the source image, but they are not computed automatically. The gdal_translate option “-stats” forces
the computation of statistics <a href="https://gdal.org/en/latest/programs/gdal_translate.html#cmdoption-gdal_translate-stats">
https://gdal.org/en/latest/programs/gdal_translate.html#cmdoption-gdal_translate-stats</a>. As a result a TIFF or COG file will have tags<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL Metadata: <GDALMetadata><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="0">YES</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="0">182</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="0">64.982910819375</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="0">18</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="0">19.488070835298</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="0">100</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="1">YES</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="1">179</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="1">68.324411498416</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="1">17</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="1">19.764307166181</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="1">100</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="2">YES</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="2">164</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="2">63.550390448167</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="2">13</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="2">16.774943130374</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="2">100</Item><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"></GDALMetadata><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">All GDAL based programs can access these tags and know their meaning. I think that you should also make your GeoTIFF/COG renderer to read the GDALMetadata instead of the baseline TIFF tags
</span><span lang="EN-US" style="mso-fareast-language:EN-US">MinSampleValue and MaxSampleValue.</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="SV" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="SV" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="SV" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<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>shark shark via gdal-dev<br>
<b>Lähetetty:</b> maanantai 25. marraskuuta 2024 5.05<br>
<b>Vastaanottaja:</b> gdal-dev@lists.osgeo.org<br>
<b>Aihe:</b> [gdal-dev] Will gdal try to write these two tags when creating tif file?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="mso-element:para-border-div;border:solid #E5E7EB 1.0pt;padding:0cm 0cm 0cm 0cm">
<p style="mso-margin-top-alt:15.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm;border:none;padding:0cm">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151">Hi! Have a good day :D<o:p></o:p></span></p>
<p style="mso-margin-top-alt:15.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm;border:none;padding:0cm;box-sizing: border-box;orphans: 2;widows: 2">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151">I'm working on a GeoTIFF/COG renderer and wondering if GDAL automatically writes the </span><code><b><span style="font-size:10.5pt;font-family:Consolas;color:#374151;border:solid #E5E7EB 1.0pt;padding:0cm">minsamplevalue</span></b></code><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151"> and </span><code><b><span style="font-size:10.5pt;font-family:Consolas;color:#374151;border:solid #E5E7EB 1.0pt;padding:0cm">maxsamplevalue</span></b></code><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151"> tags
when creating a TIFF file, especially for large files. <o:p></o:p></span></p>
<p style="mso-margin-top-alt:15.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm;border:none;padding:0cm;box-sizing: border-box;orphans: 2;widows: 2">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151">I just made a cog with goal and I didn’t find these tags. And I didn’t find a guarantee about these tagsin gdal doc. <o:p></o:p></span></p>
<p style="mso-margin-top-alt:15.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm;border:none;padding:0cm;box-sizing: border-box;orphans: 2;widows: 2">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151">Thanks for your help!<o:p></o:p></span></p>
<p style="mso-margin-top-alt:15.0pt;margin-right:0cm;margin-bottom:15.0pt;margin-left:0cm;border:none;padding:0cm;box-sizing: border-box;orphans: 2;widows: 2">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#374151">Best, Lucas.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>