Header

Rescale your raster data layer

Author: Paulo van Breugel
Updated on: 2014-02-25

Introduction

Sometimes you want to rescale a raster layer, e.g., to reduce the number of categories, or to create a common scale for different raster layers. Very basic of course, so you can expect to find an appropriate function in any self-respecting GIS software. Just be aware that different terms are being used for the same thing, e.g., scale in gdal, rescale in GRASS and normalize in SAGA GIS. Below a few ways to do this using my favourite GIS programs: GRASS GIS, QGIS, SAGA GIS or GDAL.

GRASS GIS

In GRASS GIS you can use the r.rescale function, which rescales the range of category values appearing in a raster map layer and, very conveniently, creates category labels that reflect the original category values that produced each category.

r.rescale input=elevation from=10,1500 output=elevation_255 to=0,255

But note, it only supports integer data. If you have floating data, you can use the r.recode function:

r.recode input=elevation output=elevation_25 rules=- << EOF
    10.1:1500.5:0.5:255
EOF

GDAL

Use the scale parameter in the gdal_translate function to rescale the input pixels values from the original range to the desired range.

gdal_translate -scale 10 1500 0 255 elevation.tif elevation_255.tif

QGIS

In QGIS you can use the SAGA GIS function grid_normalisation (available through the Processing toolbox in QGIS under SAGA) or the above-mentioned gdal_translate function, which is available under the raster menu or in the Processing toolbox under GDAL/OGR algorithms.

SAGA GIS

SAGA GIS function grid_normalisation.

Pick your choice

The nice thing about having different options is that you are very likely to find a way that fits best in your work flow, whether it involved the command line or GUI.

If you have questions

If you have questions or comments about the text, let me know. You can use this contact form. Please make sure to include the page title ("Rescale your raster data layer") or page name ("rescale raster layer").