In your LUT, create a range where everything less than -100 (i.e. -32768 to -101) is given a single value to set as NoData (i.e. -32768). All values in between will get assigned that single value. Then set valid min and max values equal to themselves and all values in between will get assigned the same value as each originally was. And if that makes no sense at all, as I'm having trouble articulating what I mean, see below...
<LUT>-32768:-32768,-101:-32768,-100:-100, 5000:5000</LUT>
| values < -101 = -32768 | values unchanged |
The vrt below worked for me:
<VRTDataset rasterXSize="1201" rasterYSize="1201">
<SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]</SRS>
<GeoTransform> -1.4200041666666667e+02, 8.3333333333333339e-04, 0.0000000000000000e+00, 6.1000416666666666e+01, 0.0000000000000000e+00, -8.3333333333333339e-04</GeoTransform>
<VRTRasterBand dataType="Int16" band="1">
<NoDataValue>-3.27680000000000E+04</NoDataValue>
<ComplexSource>
<SourceFilename relativeToVRT="1">N60W142.hgt</SourceFilename>
<SourceBand>1</SourceBand>
<SourceProperties RasterXSize="1201" RasterYSize="1201" DataType="Int16" BlockXSize="1201" BlockYSize="1" />
<SrcRect xOff="0" yOff="0" xSize="1201" ySize="1201" />
<DstRect xOff="0" yOff="0" xSize="1201" ySize="1201" />
<LUT>-32768:-32768,-101:-32768,-100:-100,5000:5000</LUT>
<NODATA>-32768</NODATA>
</ComplexSource>
</VRTRasterBand>
</VRTDataset>
Thanks for all of the suggestions and help. The scale normalization is very useful when doing code, however in my case the original idea of putting the minimum and maximum in code looks like the only solution at this point.
I did not find a solution for doing it at the command line.
Here is a code snippet from the working solution:
(Note that originally I was writing nodata to 0 as well, and this method breaks the nodata transformation. In my code I had to re-run the translate with nodata set to 0 as the only transformation to get it to finish the whole task!)
from qgis.core import *
from qgis.utils import *
from qgis.gui import *
import processing
from PyQt4.QtCore import *
#define functions
def loadraster(cur_raster):
fileInfo = QFileInfo(cur_raster)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(cur_raster, baseName)
if not rlayer.isValid():
print "Layer failed to load!"
return rlayer
proj = QgsProject.instance()
proj.clear()
infile = "C:/QGISwork/ving_script/mergetest.tif"
outfile = "C:/QGISwork/ving_script/mergetest_out.tif"
#load raster file
mlayer = loadraster(infile)
#this part gets the extent from the original file
ext = mlayer.extent()
extrep = ','.join([unicode(ext.xMinimum()), unicode(ext.xMaximum()), unicode(ext.yMinimum()), unicode(ext.yMaximum())])
#now get the stats whcih contain min and max values
renderer = mlayer.renderer()
provider = mlayer.dataProvider()
extent = mlayer.extent()
stats = provider.bandStatistics(1, QgsRasterBandStats.All,extent, 0)
print stats.minimumValue
print stats.maximumValue
#we don't need the layer any more so clear memory
QgsMapLayerRegistry.instance().removeMapLayer(mlayer.id())
#Run the algorithm with all of the inputs:
processing.runalg('gdalogr:translate', infile, 100, True, "0", 0, "", extrep , False, 5, 4, 75, 6, 1, False, 3, False, "-scale "+str(stats.minimumValue)+" "+str(stats.maximumValue)+" "+"0 1", outfile)
Best Answer
You could solve it using a Bash script and Awk: