I have a raster layer with nodata pixels and I want these to be 0. I have tried the SAGA tool "reclassify values", the GDAL "fill nodata" (also with a validity mask containing only zeroes) and the SAGA "close gaps".
My problem is that with all these, the other values are also being changed –for example, the maximum value in my initial raster layer is 32.94 but after the reclassification, the maximum value is 29.4.
I don't understand why the other values are also being transformed!?
Best Answer
QGIS shows min/max values at 2%/98% quantiles by default, and replacing nodata by zero(0), or adding zeros to the dataset, can shift its range.
Let me try to illustrate what (i think) had happened, using a sample dataset taken from USGS Lake Tahoe Basin.
The above
Layers Panel
shows 2 layers,Reclassified Grid
which came from SAGA "reclassify values" tool which replaced NoData values oftahoedems
(original DEM) by zero (0).We notice its maximum value also changed from 9327.77 to 9275.77. It is confirmed by Min (0) and Max (9275.77) values on the
Layer properties | Style
. (see below image)----- Min and Max values (default display) of Reclassifed raster ----
However, what we are looking at the above image is
Cumulative count cut
(2%~98%).Changing the setting to
Min/max
andAccuracy | Actual (slower)
gives us real data range. (0 ~ 10890, as below)----- Min and Max values (actual range) of Reclassifed raster ----
This maximum value of the original raster (tahoedems), which range 4616~10890 ft confirms that maximum (10890) remains unchanged.
----- Min and Max values (actual range) of original DEM ----
The distribution of cell values, which was 4616-10890 originally, was skewed toward lower-side by adding 0-values where there were no data (in other words there were NoData cells). This shifted 2%/98% cumulative count, so it looked as if it changed maximum value, too.