<div dir="ltr">I do not know that code. But having a look I have the impression that you have to set the nodata also to papszCreateOptions, so the created dataset has it.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 3 Nov 2023 at 21:36, Fitch, Simeon via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div><br></div><div>I'm one of the maintainers at the `georust/gdal` bindings project. 👋 </div><div><br></div><div>I'm currently working on exposing some of the GDAL Warp functionality in Rust, starting with a simple wrapper around `GDALCreateAndReprojectImage`. I'm having trouble getting the output file to include a no-data value in the band's metadata, despite the Warp operation properly respecting no-data values specified in `GDALWarpOptions`. </div><div><br></div><div>My C++ skills are very "rusty", so I'm hoping I can get away with explaining my problem with some Rust code that is pretty close to being 1:1 with the C API. My suspicion is I'm missing a step in the `GDALWarpOptions` setup.</div><div><br></div><div>This is the CLI operation I'm trying to replicate:<br><br>    gdalwarp -t_srs EPSG:4269 -dstnodata 255 -r near input.tif output.tif</div><div><br></div><div><div>Here's the bare-bones Rust bindgen version:<br></div><div><br></div><div>    <<a href="https://gist.github.com/metasim/d2a288d5b6126438aaa84b9e95707aff" target="_blank">https://gist.github.com/metasim/d2a288d5b6126438aaa84b9e95707aff</a>><br></div><div><br></div></div><div>The single band in `input.tif` is described by `gdalinfo` like this:<br></div><div><br></div><div>    Band 1 Block=186x44 Type=Byte, ColorInterp=Gray<br></div><div>      NoData Value=255<br>      Metadata:<br>        CLASSES=3<br></div><div><br></div><div><div>After running the Rust code, the results are correct (including Warp numerically respecting source and destination no-data values) _except_ `output.tif` does not have a no-data value in the band metadata. Here's what `gdalinfo` on `output.tif` shows:</div></div><div><br></div><div>    Band 1 Block=210x39 Type=Byte, ColorInterp=Gray<br></div><div><br></div><div>The only way I've been able to get the behavior I need is to open the written dataset from the filesystem and set the no-data value explicitly in the band, which is inefficient and awkward. Given the CLI version does the right thing, it's obviously possible. I've spent several hours visually inspecting the C++ source code, but the CLI version doesn't call `GDALCreateAndReprojectImage` directly; rather it constructs the Warp pipeline itself.</div><div><br></div><div>Anyone have tips that might help me run this down? Am I missing a no-data handling step required when working with Warp routines? Could `GDALCreateAndReprojectImage` have a bug? </div><div><br></div><div>Thanks,</div><div><br></div><div>Simeon</div><div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Simeon Fitch</div><div>Co-founder & CTO</div><div><span style="font-size:small">Astraea, Inc.</span><br style="font-size:small"></div><div><span style="font-size:small"><br></span></div></div></div></div></div>

<br>
<font face="Verdana" color="#808080" size="1">The content of this email is intended for the person or entity to which it is addressed only. This email may contain confidential information. If you are not the person to whom this message is addressed, be aware that any use, reproduction, or distribution of this message is strictly prohibited. If you received this in error, please contact the sender and immediately delete this email and any attachments.</font><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>