cogeotiff/rio-tiler

nodata value being ignored for NaN

Closed this issue · 2 comments

The #672 do not work with numpy NaN.
numpy.float32('nan') == numpy.float32('nan') and numpy.float64('nan') == numpy.float64('nan') are evaluated False.

Proposal (Line 240 in rio-tiler/rio_tiler/reader.py):

            # if data has Nodata then we simply make sure the mask == the nodata
            if nodata is not None:
                if numpy.isnan(nodata):
                    data.mask = numpy.isnan(data.data)
                else:
                    data.mask = data.data == nodata

The tile form my float32 dataset with NaN as nodata before:

tile_b

And after:

tile

Thanks!

thanks for the report @cerolinx 🙏

would you be able to submit a PR (with tests)?

Thanks

closed in #691