In remote sensing data analyses, usually we have to convert Landsat data to Top of Atmosphere value. This process will change the original digital number, in Landsat 5 from 8 bit to decimal with the range between 0 and 1. If the data is Landsat 8 then it will change from 16bit data to decimal with range between 0 and 1.
If you want to analyze the ToA (reflectance), i.e., land cover classification, you can directly use the image. The problem will appear if you want to analyze with certain formula that require 8bit data, for example Forest Canopy Density Model. So, after you do radiometric correction to reflectance, you have to rescale into 8bit integer.
Usually I use GRASS GIS for this purpose. But somehow today I found it’s difficult to use GRASS GIS. The result seems strange. After hours of trying, I found I trick to do the process.
GDAL to the rescue
We can use gdal_translate to convert data from any kind of range into 8bit integer. There are two steps to do this :
- Investigate the statistics of the data source. Use the minimum and maximum value in the data source
- gdal_info filename.tif -stats
- Translate the data using gdal_translate command
- gdal_translate -of GTiff -ot Byte -scale 0.010000000000004 0.38453308863717 1 255 source.tif target.tif