OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.79k stars 2.51k forks source link

GetNoDataValue returning wrong value #5431

Closed jontwo closed 2 years ago

jontwo commented 2 years ago

Expected behavior and actual behavior.

When upgrading a Python application to GDAL 3.4.1, a test was failing due to GetNoDataValue returning a different value to previous versions.

Steps to reproduce the problem.

test_data.tar.gz Using the following Python code, the nodata value returned at GDAL 3.3.3 is -999.0 and at GDAL 3.4.1 it is -3.4028234663852886e+38

    ds = gdal.OpenEx('test_input_1.tif)
    print(ds.GetRasterBand(1).GetNoDataValue())

Operating system

Rocky Linux 8.5 Linux version 4.18.0-348.12.2.el8_5.x86_64 (mockbuild@dal1-prod-builder001.bld.equ.rockylinux.org) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC)) #1 SMP Wed Jan 19 17:53:40 UTC 2022

GDAL version and provenance

Wheel build based on the recipe at https://github.com/sgillies/frs-wheel-builds

Versions: https://download.osgeo.org/libtiff/tiff-4.3.0.tar.gz http://download.osgeo.org/geos/geos-3.10.0.tar.bz2 http://download.osgeo.org/proj/proj-8.1.1.tar.gz http://download.osgeo.org/gdal/3.4.1/gdal-3.4.1.tar.gz

Options: ./configure \ --with-threads \ --disable-debug \ --disable-static \ --without-grass \ --without-libgrass \ --without-jpeg12 \ --with-libtiff \ --with-jpeg \ --with-gif \ --with-png \ --with-webp \ --with-geotiff=internal \ --with-sqlite3=/usr \ --with-spatialite \ --with-pcraster=internal \ --with-pcidsk=internal \ --with-pam \ --with-geos=/usr/local/bin/geos-config \ --with-proj=/usr/local \ --with-expat=/usr/local \ --with-libjson-c \ --with-libiconv-prefix=/usr \ --with-libz=/usr \ --with-curl=/usr/local/bin/curl-config \ --with-netcdf=/usr/local/netcdf \ --with-openjpeg \ --without-python \ --without-hdf4 \ --without-hdf5 \ --with-fgdb=/usr/local/src/FileGDB_API-64 \ --with-pg=yes \ --disable-driver-elastic \

rouault commented 2 years ago

I get the correct result -999 with the current state of the GDAL 3.4 branch / 3.4.2, and I've no reason to believe it to be different with 3.4.1 Perhaps you have also a test_input_1.tif.aux.xml file that overrides the nodata value ?

jontwo commented 2 years ago

I do - I thought it only contained the stats so ignored it, but it does contain the line

<NoDataValue le_hex_equiv="000000E0FFFFEFC7">-3.40282346638529E+38</NoDataValue>

Is this ignored at v3.3.3?

jratike80 commented 2 years ago

Could you please annex also the aux.xml file?

rouault commented 2 years ago

Is this ignored at v3.3.3?

yes, support for reading nodata value from aux.xml is a 3.4.1 bugfix

jontwo commented 2 years ago

test_aux_xml.tar.gz Thanks for your help, I have this working now.