<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Le 11/11/2022 à 19:12, Javier Jimenez
Shaw a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CADRrdKsMrFbmBwNsvJiTyDKog83Ru6QKWGvrZdx0Tr5tyAUgig@mail.gmail.com">
<div dir="ltr">
<div>Hi</div>
<div><br>
</div>
<div>I am creating a GeoTIFF file with C++. It is a large DSM
(one band of Float32). Because I am generating it, I already
know the min and max values.</div>
<div>I would like to store the min and max values directly in
the TIFF, not in a sidecar file. Is there any gdal metadata
(stored in the TIFF) that can be used? That way, when I open
it in QGIS, the range of the band will be accurate.<br>
</div>
</div>
</blockquote>
<p>yep, see <a class="moz-txt-link-freetext" href="https://gdal.org/user/raster_data_model.html#raster-band">https://gdal.org/user/raster_data_model.html#raster-band</a></p>
<p>Demo:</p>
<p>$ python<br>
from osgeo import gdal<br>
ds = gdal.GetDriverByName('GTiff').Create('test.tif', 1, 1)<br>
ds.GetRasterBand(1).SetMetadataItem('STATISTICS_MINIMUM', '0')<br>
ds.GetRasterBand(1).SetMetadataItem('STATISTICS_MAXIMUM', '1')<br>
ds.GetRasterBand(1).SetMetadataItem('STATISTICS_MEAN', '2')<br>
ds.GetRasterBand(1).SetMetadataItem('STATISTICS_STDDEV', '3')<br>
<br>
<br>
$ gdalinfo test.tif<br>
Driver: GTiff/GeoTIFF<br>
Files: test.tif<br>
Size is 1, 1<br>
Image Structure Metadata:<br>
INTERLEAVE=BAND<br>
Corner Coordinates:<br>
Upper Left ( 0.0, 0.0)<br>
Lower Left ( 0.0, 1.0)<br>
Upper Right ( 1.0, 0.0)<br>
Lower Right ( 1.0, 1.0)<br>
Center ( 0.5, 0.5)<br>
Band 1 Block=1x1 Type=Byte, ColorInterp=Gray<br>
Min=0.000 Max=1.000 <br>
Minimum=0.000, Maximum=1.000, Mean=2.000, StdDev=3.000<br>
Metadata:<br>
STATISTICS_MAXIMUM=1<br>
STATISTICS_MEAN=2<br>
STATISTICS_MINIMUM=0<br>
STATISTICS_STDDEV=3</p>
<p>$ tiffdump -m 1000 test.tif<br>
test.tif:<br>
Magic: 0x4949 <little-endian> Version: 0x2a
<ClassicTIFF><br>
Directory 0: offset 8 (0x8) next 0 (0)<br>
ImageWidth (256) SHORT (3) 1<1><br>
ImageLength (257) SHORT (3) 1<1><br>
BitsPerSample (258) SHORT (3) 1<8><br>
Compression (259) SHORT (3) 1<1><br>
Photometric (262) SHORT (3) 1<1><br>
StripOffsets (273) LONG (4) 1<402><br>
SamplesPerPixel (277) SHORT (3) 1<1><br>
RowsPerStrip (278) SHORT (3) 1<1><br>
StripByteCounts (279) LONG (4) 1<1><br>
PlanarConfig (284) SHORT (3) 1<1><br>
SampleFormat (339) SHORT (3) 1<1><br>
42112 (0xa480) ASCII (2) 244<<GDALMetadata>\n <Item
name="STATISTICS_MAXIMUM" sample="0">1</Item>\n <Item
name="STATISTICS_MEAN" sample="0">2</Item>\n <Item
name="STATISTICS_MINIMUM" sample="0">0</Item>\n <Item
name="STATISTICS_STDDEV"
sample="0">3</Item>\n</GDALMetadata>\n\0><br>
<br>
</p>
<p>Even<br>
</p>
<blockquote type="cite"
cite="mid:CADRrdKsMrFbmBwNsvJiTyDKog83Ru6QKWGvrZdx0Tr5tyAUgig@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>Thanks.<br>
</div>
<div>
<div>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">.___ ._ ..._ .. . ._.
.___ .. __ . _. . __.. ... .... ._ .__<br>
Entre dos pensamientos racionales <br>
hay infinitos pensamientos irracionales.<br>
<br>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>