Changing min and max values for raster layer in QGIS

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

Tags:

Qgis