<div dir="ltr"><div dir="ltr">Hi Even,<div><br></div><div>Thanks for your reply!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 19 Jan 2024 at 17:32, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
I can't think an easy way of doing what you want.<br></blockquote><div><br></div><div>Is there a functional gap? <i>Conceptually</i> it feels to me like <font face="monospace">VRTRasterBand.ComplexSource.UseMaskBand</font> should "mark" a pixel to be nodata-equivalent (NaN?), and then <font face="monospace">VRTRasterBand.NoDataValue</font> should "write" the nodata-marked pixels with the value.</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div><font face="monospace"><VRTDataset ...></font></div></div><div class="gmail_quote"><div><font face="monospace">  ...</font></div></div><div class="gmail_quote"><div><font face="monospace">  <VRTRasterBand dataType="Int16" band="1"></font></div></div><div class="gmail_quote"><div><font face="monospace">    <NoDataValue>-1</NoDataValue></font></div></div><div class="gmail_quote"><div><font face="monospace">    <ComplexSource></font></div></div><div class="gmail_quote"><div><font face="monospace">      <SourceFilename>in.tif</SourceFilename></font></div></div><div class="gmail_quote"><div><font face="monospace">      <SourceBand>1</SourceBand></font></div></div><div class="gmail_quote"><div><font face="monospace">      <UseMaskBand>true</UseMaskBand></font></div></div><div class="gmail_quote"><div><font face="monospace">      ...</font></div></div><div class="gmail_quote"><div><font face="monospace">    </ComplexSource></font></div><div><font face="monospace">    ...</font></div></div><div class="gmail_quote"><div><font face="monospace">  </VRTRasterBand></font></div></div></blockquote><div class="gmail_quote"><div><br></div><div>But maybe that's not how it's modelled inside?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
Well, you can definitely do that using a VRT Python pixel function, that <br>
would essentially do your --calc expression<br></blockquote><div><br></div><div>Thanks for confirming it's possible, I'll have a play. </div><div><br></div><div>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?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>A nice exercice for (Pythonist) contributors would be to add a -f VRT <br>
capability to gdal_calc.py that would essentially automate the writing <br>
of such VRT using Python pixel functions. Just saying...</blockquote><div><br></div><div>*adds to a long list of nice exercises*</div><div><br></div><div>Thanks</div><div><br></div><div>Rob :)</div></div></div>