I'm attempting to set the nodata value on an NITF image and then subsequently read this nodata value back out of the image. However this read fails to find the newly set nodata value. See the attached source code and an example image. You can see that the nodata value is being set for (the first band of) the image in the PAM XML file.
Any ideas? FYI....I'm using version 1.5.2. Thanks, Matt Klaric
#include <iostream> using namespace std; #include <gdal_priv.h> int main(int argc, char** argv) { GDALAllRegister(); //////////////////////////////////////////////////// // open a file for update GDALDataset* dataset = (GDALDataset *) GDALOpen("mosaic-test-5x5.ntf", GA_Update); if (dataset == NULL) { std::cout << "ERROR: Could not open file" << std::endl; return 1; } //////////////////////////////////////////////////// // get the band out of the dataset GDALRasterBand* band = dataset->GetRasterBand(1); if (band == NULL) { std::cout << "ERROR: Couldn't get band" << std::endl; return 2; } //////////////////////////////////////////////////// // set the nodata value explicitly if(CE_Failure == band->SetNoDataValue(9)) { std::cout << "ERROR: Failed to set no data value" << std::endl; } else { std::cout << "Set nodata value" << std::endl; } std::cout << "***********************" << std::endl; //////////////////////////////////////////////////// // now pull out the nodata value to sanity check int success; double noDataValue = band->GetNoDataValue(&success); switch (success) { case TRUE: std::cout << "Found a nodata value of " << noDataValue << std::endl; break; case FALSE: std::cout << "Didn't find a nodata value" << std::endl; break; default: std::cout << "Confused" << std::endl; } //////////////////////////////////////////////////// // cleanup dataset->FlushCache(); GDALClose(dataset); return 0; }
mosaic-test-5x5.ntf
Description: Binary data
mosaic-test-5x5.ntf.aux.xml
Description: XML document
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev