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!?

  • Welcome to gis.stackexchange! A question to clarify; Are you seeing these maximum values (29.4 and 32.94) on the Layers Panel and Layer Properties | Style perhaps? QGIS usually shows values at 2%/98% quantiles. If it is the case, you can check real Min/max values by hitting [Load] button after toggle on the Min/max option in the Load min/max values on Layer Properties | Style tab.
    – Kazuhito
    Apr 23, 2017 at 4:36
  • @Kazuhito thanks for your answer! I checked in the Layer Properties and loaded the min/max values and I saw that they are the same, -thank you for this tip! But obviously, "no data" values are not replaced by 0 but by other arbitrary values, even when I use a 0 value mask. how can I get exclusively zeroes to replace the no data pixels?
    – Florence
    Apr 23, 2017 at 16:02
  • Thanks for your feedback. Can you add some more information about the other arbitrary value? Is it any particular value?
    – Kazuhito
    Apr 23, 2017 at 16:08
  • the values are between 10 and 20 with "close gaps" and very irregular after I ran "fill nodata" but with the latter, it seems like qgis creates its own new grid with horizontal, vertical and diagonal bands of similar values
    – Florence
    Apr 23, 2017 at 16:15
  • I see. Both "close gaps" and "fill nodata" uses values from nearby cells, most reliable tool would be SAGA "reclassify values" tool for this operation.
    – Kazuhito
    Apr 23, 2017 at 16:21

1 Answer 1


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.

enter image description here

The above Layers Panel shows 2 layers, Reclassified Grid which came from SAGA "reclassify values" tool which replaced NoData values of tahoedems (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 ----

enter image description here

However, what we are looking at the above image is Cumulative count cut (2%~98%).

Changing the setting to Min/max and Accuracy | Actual (slower) gives us real data range. (0 ~ 10890, as below)

----- Min and Max values (actual range) of Reclassifed raster ----

enter image description here

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 ----

enter image description here

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.