<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Javier,</p>
<p>mixing Alpha and NoData is generally not a good idea. Behavior
will be different according to which part of the code is
triggered. As far as I can see, the warping code should be able to
handle both, but overview building will use the return of
GDALRasterBand::GetMaskBand(), and when you have both nodata and
alpha, this should be from the nodata value.</p>
<p>Confirmed by the following little experiment, so I'm not sure why
you get what you get:<br>
</p>
<p>$ cat test.asc<br>
ncols 2<br>
nrows 2<br>
xllcorner 440720.000000000000<br>
yllcorner 3750120.000000000000<br>
cellsize 60.000000000000<br>
NODATA_value -10000<br>
0.5 1.0<br>
2.5 -10000</p>
<p>$ cat test_alpha.asc <br>
ncols 2<br>
nrows 2<br>
xllcorner 440720.000000000000<br>
yllcorner 3750120.000000000000<br>
cellsize 60.000000000000<br>
NODATA_value -10000<br>
255 255<br>
255 255</p>
<p>$ cat tmp.vrt <br>
<VRTDataset rasterXSize="2" rasterYSize="2"><br>
<GeoTransform> 4.4072000000000000e+05,
6.0000000000000000e+01, 0.0000000000000000e+00,
3.7513200000000000e+06, 0.0000000000000000e+00,
-6.0000000000000000e+01</GeoTransform><br>
<VRTRasterBand dataType="Float32" band="1"><br>
<NoDataValue>-10000</NoDataValue><br>
<ComplexSource><br>
<SourceFilename
relativeToVRT="1">test.asc</SourceFilename><br>
<SourceBand>1</SourceBand><br>
<NODATA>-10000</NODATA><br>
</ComplexSource><br>
</VRTRasterBand><br>
<VRTRasterBand dataType="Float32" band="2"><br>
<NoDataValue>-10000</NoDataValue><br>
<ColorInterp>Alpha</ColorInterp><br>
<ComplexSource><br>
<SourceFilename
relativeToVRT="1">test_alpha.asc</SourceFilename><br>
<SourceBand>1</SourceBand><br>
<NODATA>-10000</NODATA><br>
</ComplexSource><br>
</VRTRasterBand><br>
</VRTDataset><br>
<br>
</p>
<div class="moz-cite-prefix">$ gdal_translate tmp.vrt test.tif<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">$ gdaladdo -r average test.tif 2</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">$ gdal_translate test.tif /vsistdout/
-of aaigrid -b 1 -outsize 1 1<br>
ncols 1<br>
nrows 1<br>
xllcorner 440720.000000000000<br>
yllcorner 3751200.000000000000<br>
cellsize 120.000000000000<br>
NODATA_value -10000<br>
1.3333333730697631836<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Even<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Le 31/05/2021 à 16:55, Javier Jimenez
Shaw a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CADRrdKsjJeePk5EP4YhyX8X=o078v=7QW5SMVgutFeHLUgc+mg@mail.gmail.com">
<div dir="ltr">
<div>Hi</div>
<div><br>
</div>
<div>I have a GeoTIFF with this characteristics:</div>
<div>- 6 bands</div>
<div>- last band is "Alpha" (with values 0 or 255, nothing else)<br>
</div>
<div>- Float32</div>
<div>- NoData value = -10000</div>
<div><br>
</div>
<div>The 5 first bands may have "nodata" pixels, not necessarily
on all bands simultaneously. (nodata pixels are usually broken
or saturated pixels from the sensor, and each band comes from
a different sensor). The valid pixels have values between 0
and 1</div>
<div><br>
</div>
<div>When I try to generate embedded overviews (with average
interpolation) with C++ or CreateCopy as COG (with default
values), looks like it is using the -10000 values as valid
values, and producing results in the overviews like -9990.6...
that obviously are not anymore considered "nodata".</div>
<div><br>
</div>
<div>The first noticeable effect opening the file in QGIS, is
that the min and max value for each band are not anymore 0 and
1, but nonsense negative numbers.<br>
</div>
<div><br>
</div>
<div>Can both Alpha and NoData live together properly?</div>
<div><br>
</div>
<div>Thanks.</div>
<div><br>
</div>
<div>PS I have the impression that with external ovr file it
does not happen. I am testing more.<br>
</div>
<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>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></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>