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.
On Fri, 3 Nov 2023 at 21:36, Fitch, Simeon via gdal-dev < gdal-dev@lists.osgeo.org> wrote: > Hi, > > I'm one of the maintainers at the `georust/gdal` bindings project. 👋 > > 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`. > > 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. > > This is the CLI operation I'm trying to replicate: > > gdalwarp -t_srs EPSG:4269 -dstnodata 255 -r near input.tif output.tif > > Here's the bare-bones Rust bindgen version: > > <https://gist.github.com/metasim/d2a288d5b6126438aaa84b9e95707aff> > > The single band in `input.tif` is described by `gdalinfo` like this: > > Band 1 Block=186x44 Type=Byte, ColorInterp=Gray > NoData Value=255 > Metadata: > CLASSES=3 > > 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: > > Band 1 Block=210x39 Type=Byte, ColorInterp=Gray > > 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. > > 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? > > Thanks, > > Simeon > > -- > Simeon Fitch > Co-founder & CTO > Astraea, Inc. > > > 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. > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/gdal-dev >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev