<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Jason,</p>
    <p>It looks like something in the code asks a float64 field to be
      returned as a int32, and thus NaN has to be turned into something
      else. That's perhaps fine in the context where that happens with
      your file and could potentially be silenced, but access to the
      file would be needed to investigate</p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 08/05/2025 à 23:01, Jason Roberts
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:2d66b13b-34e6-460d-a687-90e0a4196eda@duke.edu">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <font face="Verdana">Hi GDAL team,<br>
        <br>
        I'm working with the GDAL Python API. I have some HFA (.img)
        files that are float32 and that use nan as their NoData value.
        As far as I can tell, using nan is allowed but I could be wrong.
        When I open them, I get "Warning 1: NaN converted to INT_MAX."
        Everything seems to work fine after that. Is this message
        something I need to worry about? If not, may I suggest you
        remove it from the HFA driver if possible?<br>
        <br>
        Here's some code demonstrating the message. If need be, I can
        provide an example file, or write some code to generate one.<br>
        <br>
        >>> import numpy as np<br>
        >>> from osgeo import gdal<br>
        >>> gdal.__version__       # this version is packaged
        with ArcGIS Pro 3.4, but I don't think the version matters<br>
        '3.9.2e'<br>
        >>> ds =
gdal.Open(r'\\conch\denmod\Covariates\NARW25\CMEMS_GLORYS\SST\1999\SST_199901.img',
        gdal.GA_ReadOnly)<br>
        Warning 1: NaN converted to INT_MAX.<br>
        >>> band = ds.GetRasterBand(1)<br>
      </font><font face="Verdana">>>>
        gdal.GetDataTypeName(band.DataType)<br>
        'Float32'<br>
      </font><font face="Verdana">>>> band.GetNoDataValue()<br>
        nan<br>
        >>> arr = band.ReadAsArray()   # the data look ok:<br>
        >>> np.isnan(arr).sum()<br>
        86788<br>
        >>> (~np.isnan(arr)).sum()<br>
        142985<br>
      </font><font face="Verdana">>>> np.max(arr)<br>
        nan<br>
      </font><font face="Verdana">>>> np.nanmax(arr)<br>
        27.078554<br>
        <br>
        As far as I can tell, the warning comes from this code in
        gdal/frmts/hfa/hfafield.cpp:<br>
        <br>
                        else if (std::isnan(dfDoubleRet))<br>
                        {<br>
                            CPLError(CE_Warning, CPLE_AppDefined,<br>
                                     "NaN converted to INT_MAX.");<br>
                            nIntRet = nMax;<br>
                        }<br>
        <br>
        But I don't know if there are any negative ramifications that
        will result.<br>
        <br>
        Thank you for your help. And, as always, thank you very much for
        developing and maintaining GDAL.<br>
        <br>
        Jason<br>
        <br>
      </font> <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>