Beyond the Artifacts: Fixing Poor Quality Raster Rescaling in QGIS
In the transition between data acquisition and visualization, "rescaling" is often a necessary evil. Whether you are converting 16-bit satellite imagery to 8-bit for a presentation or normalizing a Digital Elevation Model (DEM) to a 0-1 range for machine learning, the process in QGIS frequently yields "bad results"—manifesting as banding (posterization), unexpected "NoData" holes, or a completely black/white canvas. These failures are rarely bugs in QGIS itself; rather, they are usually mathematical mismatches between the input bit-depth, the resampling algorithm, and the output data type. This tutorial breaks down the technical reasons for these artifacts and provides the specific workflows to maintain radiometric integrity during a rescale.
Table of Content
- Purpose: Maintaining Radiometric Precision
- Common Causes of Rescale Failure
- Step-by-Step: The "Clean Rescale" Workflow
- Use Case: Normalizing SAR Data for Analysis
- Best Results: Choosing the Right Bit-Depth
- FAQ
- Disclaimer
Purpose
The goal of this guide is to eliminate the most common rescaling errors in QGIS, focusing on:
- Bit-Depth Preservation: Preventing the loss of data resolution when moving between Int16, Float32, and Byte formats.
- Range Normalization: Successfully mapping old min-max values to a new scale without clipping the tails of the histogram.
- Visual Fidelity: Avoiding the "staircase" effect in gradients and elevation models.
Common Causes of Rescale Failure
When QGIS produces a "bad" rescale, it is usually due to one of three issues:
- Integer Truncation: Rescaling a 0-255 range to 0-1 using an Integer output type, which rounds every pixel to either 0 or 1.
- NoData Bleed: Statistical functions accidentally including -9999 values in the min/max calculation, causing the real data to be squashed into a tiny, invisible fraction of the histogram.
- Algorithm Mismatch: Using "Nearest Neighbor" resampling on continuous data (like slopes), which creates jagged pixel boundaries.
Step-by-Step: The "Clean Rescale" Workflow
1. Verify Source Statistics
Right-click your layer > Properties > Information. Check the "Data Type" (e.g., Float32) and the actual Min/Max values. If statistics are missing or "estimated," run Processing Toolbox > Compute Raster Statistics first.
2. Use Raster Calculator for Precision
For a perfect 0-1 normalization, use the following formula in the Raster Calculator:
("Raster@1" - [MIN]) / ([MAX] - [MIN])
Example: If your range is 150 to 1200, the formula is ("Raster@1" - 150) / (1205 - 150). Ensure the Output Layer is set to Float32.
3. The GDAL Translate Method (Scale Flag)
To rescale 16-bit data to 8-bit (0-255) for visualization without the "black screen" effect:
- Go to Raster > Conversion > Translate (Convert Format).
- In the "Advanced Parameters" or "Additional Command Line Options," add:
-scale [src_min] [src_max] 0 255. - Set the Output Data Type to
Byte.
4. Set the Resampling Algorithm
In the Processing Toolbox > Rescale Raster tool, ensure you change the "Resampling Method" to Bilinear or Cubic for continuous data (elevations/indices) to avoid pixelated "bad results."
Use Case: Normalizing SAR Data for Analysis
A researcher is working with Sentinel-1 SAR backscatter values which range from -30 to +5 dB. They need this data in a 0-255 format for a specific image processing script.
- The Mistake: They used the standard "Stretch" in the Symbology tab, but the exported file still contained the original negative values.
- The Fix: They used GDAL Translate with the
-scale -30 5 0 255parameter and anUInt16output. - The Result: A high-contrast, perfectly scaled image where the lowest backscatter is 0 and the highest is 255, with no data loss.
Best Results
| Scenario | Best Tool | Recommended Data Type |
|---|---|---|
| 0 to 1 Normalization | Raster Calculator | Float32 |
| 16-bit to 8-bit (Visual) | GDAL Translate (-scale) | Byte |
| Removing Outliers | r.rescale (GRASS) | Int32 / Float32 |
| Merging Tiles | Build Virtual Raster | Match Input |
FAQ
Why is my rescaled raster completely black?
This is usually a rendering issue, not a data issue. QGIS symbology often "remembers" the old min/max. Go to Layer Properties > Symbology and click "Min/Max Value Settings" > "Load" to refresh the view based on the new 0-1 or 0-255 range.
Should I use 'Rescale' or 'Stretch'?
Stretch usually refers to the visual representation (Symbology). Rescale actually changes the underlying cell values in the file. For GIS analysis, you always want to rescale the data itself.
What happens to NoData values?
If not handled, NoData values (like -9999) can be treated as real numbers during math operations, ruining the rescale. Always define your NoData value in the tool settings to ensure it is ignored during the calculation.
Disclaimer
Rescaling is a destructive process when moving from higher bit-depths (e.g., Float64) to lower ones (e.g., Byte). You cannot "undo" the precision loss once the data is saved in a lower-resolution format. Always maintain a backup of your raw floating-point data. March 2026.
Tags: QGIS_Raster, Data_Stretching, GDAL_Tutorial, GIS_Troubleshooting