[gdal-dev] Convert alpha to nodata?
Robert Coup
robert.coup at koordinates.com
Mon Jan 22 05:26:46 PST 2024
Hi Even,
Thanks for your reply!
On Fri, 19 Jan 2024 at 17:32, Even Rouault <even.rouault at spatialys.com>
wrote:
> I can't think an easy way of doing what you want.
>
Is there a functional gap? *Conceptually* it feels to me like
VRTRasterBand.ComplexSource.UseMaskBand should "mark" a pixel to be
nodata-equivalent (NaN?), and then VRTRasterBand.NoDataValue should "write"
the nodata-marked pixels with the value.
<VRTDataset ...>
...
<VRTRasterBand dataType="Int16" band="1">
<NoDataValue>-1</NoDataValue>
<ComplexSource>
<SourceFilename>in.tif</SourceFilename>
<SourceBand>1</SourceBand>
<UseMaskBand>true</UseMaskBand>
...
</ComplexSource>
...
</VRTRasterBand>
But maybe that's not how it's modelled inside?
> Well, you can definitely do that using a VRT Python pixel function, that
> would essentially do your --calc expression
>
Thanks for confirming it's possible, I'll have a play.
>From what I can see the python pixel functions are only called once,
use numpy and (IIUC) vectorised CPU operations... would that make it
faster/comparable to one of the C pixel functions that's doing a naive
array loop over rows & columns?
> A nice exercice for (Pythonist) contributors would be to add a -f VRT
> capability to gdal_calc.py that would essentially automate the writing
> of such VRT using Python pixel functions. Just saying...
*adds to a long list of nice exercises*
Thanks
Rob :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240122/3fcb7d6a/attachment.htm>
More information about the gdal-dev
mailing list