Following the steps this tutorial (step 6), I'm trying to change the minimum and maximum values in a raster DEM. The current range is -6.24 to 3074.67, and I need it to scale from 0 to 65535. Unfortunately I can't figure out how to do this!

The most promising tool seemed to be r.rescale from GRASS, but it gave me the following error message:

The default nodata value is present in rasterband <output5219bf1d25af4b58b13ce1baeb6dfcd7> and would lead to data loss. Please specify a custom nodata value with the nodata parameter.

and since I cannot figure out how to set the nodata parameter, this obviously didn't work. Can anyone help me figure out how to rescale this raster, using r.rescale or any other tool in QGIS 3.6.2?

  • QGIS 3.1 or 3.10? Nov 2, 2019 at 0:48
  • Sorry, not 3.1 at all. Actually QGIS Desktop 3.6.2. Edited OP to reflect this.
    – user72959
    Nov 2, 2019 at 2:01

2 Answers 2


You could try SAGA Change data storage tool (in QGIS Processing Toolbox > Raster tools).

Select Unsigned 2 byte integer which is requested by your tutorial step 6. Rescaling is automatically done but it depends on the original data type.

If needed, you can change the data range with Scale parameters, but I wonder how do you want to treat the negative value: below sea level?

enter image description here


It seems to me that you have a value assigned to no-data that is between -6.24 and 3074.67.
There are, at least, two ways to deal with it:

  1. Using the raster calculator with the formula: ( "<DEM layer name>" + 6.24 ) / 3080.91 * 65535.
    It will linearly extrapolate the not NULL values of the DEM.
    This is the option that the tutorial points to.
    I just updated QGIS to version 3.10.0 and the raster calculator seems to be not working, so you should check that your version works correctly.
    In the last long term release (3.4.13) it works fine.
    The output will be a Float32 format file which you must then convert to unsigned 16-Bit, as indicated in the tutorial.

  2. Remove or reassign the nodata values to the original DEM with gdalwarp.
    You can remove it through the command: gdalwarp -srcnodata None DEM_file_name.tif new_file_name.tif.
    Or you can reassign them (i.e. if it was 0) to another value outside the [-6.24 ; 3074.67] range (i.e to -9999) through the command: gdalwarp -srcnodata 0 -dstnodata -9999 DEM_file_name.tif new_file_name.tif. Note that it will change the value of that pixels.
    Next, rescale the new file with the r.rescale algorithm in QGIS.
    This will also interpolate the values you had assigned to nodata if you remove the assign, or it will interpolate just not NULL values if you reassign them.
    The output will already be an unsigned 16-Bit file, with a color palette, and the new value for nodata will be 65535 (this is the value that cannot be changed since the -nodata prameter is not included in the QGIS algorithm for the GRASS r.rescale command).

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.