Skip to main content
Generalised for cases where smin != 0 (smax - smin term)
Source Link
Simbamangu
  • 14.9k
  • 7
  • 60
  • 93

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * (smax - smin) / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * (smax - smin) / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0
improved formatting
Source Link
urcm
  • 22.6k
  • 4
  • 58
  • 109

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0
Source Link
Jeffrey Evans
  • 32k
  • 2
  • 48
  • 97

The following will stretch your data to 8-bit (0-255).

smin=0; smax=255

( x - min(x) ) * smax / ( max(x) - min(x) ) + smin

It should be fairly easy to translate this to the raster algebra syntax in your software of choice. You will just need to know what the min and max values are in your raster. If the raster is the result of a band ratio then it is safe to assume -1 to 1 and the syntax should look something like this.

NewRaster = ( OldRaster - -1 ) * 255 / ( 1 - -1 ) + 0