#6578 closed defect (fixed)
Mask set to nodata for values near nodata
Reported by: | Mike Taves | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | 2.1.0 |
Severity: | normal | Keywords: | |
Cc: |
Description
This issue is partially described for QGIS here http://hub.qgis.org/issues/15202
I've attached a Float32 raster calculated with gdal_calc.py (prior to [34037]), which has a nodata of 1.175494351E-38 and at least one pixel with a value of 0.0. ArcGIS correctly distinguishes between the 0.0 value and nodata value pixels, but QGIS and GDAL's GetMaskBand consider both of these as nodata.
from osgeo import gdal ds = gdal.Open('C.tif') b = ds.GetRasterBand(1) mb = b.GetMaskBand() print(mb.ReadAsArray()) [[ 0 255 255 255] [255 0 255 255] [255 255 255 255]]
The expected result should be:
[[255 255 255 255] [255 0 255 255] [255 255 255 255]]
Or with numpy as a masked array:
import numpy as np ar = np.ma.masked_equal(b.ReadAsArray(), b.GetNoDataValue()) print(repr(ar)) masked_array(data = [[0.0 -0.100000023842 -0.200000047684 -0.299999952316] [-0.400000095367 -- -0.599999904633 -0.699999809265] [-0.800000190735 -0.89999961853 -1.0 -1.10000038147]], mask = [[False False False False] [False True False False] [False False False False]], fill_value = 1.17549e-38)
Attachments (1)
Note:
See TracTickets
for help on using tickets.
This is due to the following test :
I guess that special cases should be made for FLT_MIN and DBL_MIN