Changing of pixel values when clipping raster by mask in QGIS

clipraster

I am using 'Clip raster by mask layer' in QGIS to clip a raster temperature layer down to the size of the area I'm interested in using a polygon. The resulting clipped layer is a raster that has pixel values significantly different from the original.

I am doing this same process with different raster layers and it usually works fine, but some clipped layers come out with pixel values totally off. This is not an issue of values display. It's just that the pixels have different values. For example, when I right-click with 'identifier features' option on a random pixel it gives me values of 26.95 in the original (which makes complete sense as this is the value of mean annual temperature) and a value of 3001 in the clipped raster.

enter image description here

Does anyone know what's going wrong?


I couldn't attach the image in my previous comment. Here it is:

enter image description here

Best Answer

Before you run the mask tool, use the GDAL Translate (convert format) tool to unscale your input raster as follows:

  1. Select tool from toolbox under GDAL->Raster conversion -> Translate
  2. Choose your input raster as the input layer for the translate tool
  3. Type -unscale -co DECIMAL_PRECISION=2 in the Additional command-line parameters (don't forget the leading hyphen)
  4. Choose output filename and location
  5. Run the Translate tool and use the output (unscaled tiff) as the input to 'clip raster from mask' as you did before.

enter image description here