<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 11pt;">
<span style="font-size: 11pt;">Thank you guys !! Saved my time a lot. :D I get </span><span style="font-size: 11pt; font-family: Calibri, sans-serif;">GDALMetadata</span><span style="font-size: 11pt;"> from tiff tag </span><span style="font-size: 11pt; font-family: Calibri, sans-serif;">42112
based on your response. </span></div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 11pt;">
<br>
</div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 11pt;">
<span style="font-family: Calibri, sans-serif; text-decoration: none; display: inline !important; background-color: rgb(255, 255, 255);"><br>
</span></div>
<div dir="ltr" style="font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 11pt;">
<span style="font-family: Calibri, sans-serif; text-decoration: none; display: inline !important; background-color: rgb(255, 255, 255);">Lucas.</span></div>
<br>
<div id="ms-outlook-mobile-signature" dir="ltr"></div>
<div id="mail-editor-reference-message-container"><span style="mso-bookmark:_MailOriginalBody">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<div style="font-family: Aptos; font-size: 12pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; padding: 3pt 0in 0in; color: black;">
<span style="font-weight:bold">From: </span>Rahkonen Jukka <jukka.rahkonen@maanmittauslaitos.fi><br>
<span style="font-weight:bold">Date: </span>Monday, November 25, 2024 at 4:07 PM<br>
<span style="font-weight:bold">To: </span>shark shark <zhangyijunmetro@hotmail.com>, gdal-dev@lists.osgeo.org <gdal-dev@lists.osgeo.org><br>
<span style="font-weight:bold">Subject: </span>Re: Will gdal try to write these two tags when creating tif file?<br>
<br>
</div>
<div class="WordSection1">
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="">Hi,</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style=""> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="">I had a try by creating a 6-bit COG<br>
gdal_translate -of cog -co nbits=6 P4433H.tif 6bit.tif</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="">tiffinfo shows:<br>
TIFF Directory at offset 0xc0 (192)</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> Image Width: 12000 Image Length: 12000</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> Tile Width: 512 Tile Length: 512</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> Resolution: 0.393677, 0.393677 pixels/cm</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> 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</p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<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
</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<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</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US">GDAL Metadata: <GDALMetadata></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="0">YES</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="0">182</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="0">64.982910819375</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="0">18</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="0">19.488070835298</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="0">100</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="1">YES</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="1">179</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="1">68.324411498416</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="1">17</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="1">19.764307166181</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="1">100</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_APPROXIMATE" sample="2">YES</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MAXIMUM" sample="2">164</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MEAN" sample="2">63.550390448167</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_MINIMUM" sample="2">13</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_STDDEV" sample="2">16.774943130374</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> <Item name="STATISTICS_VALID_PERCENT" sample="2">100</Item></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"></GDALMetadata></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<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="">MinSampleValue and MaxSampleValue.</span><span lang="EN-US"></span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="SV" style="">-Jukka Rahkonen-</span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="SV" style=""> </span></p>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="SV" style=""> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
<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?</p>
</div>
</div>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
<div>
<div style="border:solid #E5E7EB 1.0pt; padding:0cm 0cm 0cm 0cm">
<p style="margin-right:0cm; margin-bottom:15.0pt; margin-left:0cm; border:none; padding:0cm">
<span style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);">Hi! Have a good day :D</span></p>
<p style="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: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);">I'm working on a GeoTIFF/COG renderer and wondering if GDAL automatically writes the </span><code style="font-family: "Courier New";"><b><span style="font-size: 10.5pt; font-family: Consolas; border: 1pt solid rgb(229, 231, 235); padding: 0cm; color: rgb(55, 65, 81);">minsamplevalue</span></b></code><span style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);"> and </span><code style="font-family: "Courier New";"><b><span style="font-size: 10.5pt; font-family: Consolas; border: 1pt solid rgb(229, 231, 235); padding: 0cm; color: rgb(55, 65, 81);">maxsamplevalue</span></b></code><span style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);"> tags
when creating a TIFF file, especially for large files. </span></p>
<p style="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: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);">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. </span></p>
<p style="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: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);">Thanks for your help!</span></p>
<p style="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: 12pt; font-family: Arial, sans-serif; color: rgb(55, 65, 81);">Best, Lucas.</span></p>
</div>
<p class="MsoNormal" style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">
</p>
</div>
</div>
</span></div>
</div>
</body>
</html>