Using gdaldem hillshade, I get a one-band hillshade (download here, 2MB) :
gdaldem hillshade crop_xl.tmp.tif Shadedrelief.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges I currently can duplicate its band 1 (grey scale) into the band 2 (alpha) via :
gdal_translate -b 1 -b 1 -co COMPRESS=LZW -co ALPHA=YES ./Shadedrelief.tmp.tif ./Shadedrelief.2bands.tmp.tif But what I want to do is to get the inverted value of band 1 into band 2. The equation is :
y = -x + 255; // where x is -b 1 's value, and y is -b 2 's value. Given a tif hillshade as provided, how to get the inverted value of band 1 into band 2 ?
See also : How to conditionnally assign a new value to pixels of a raster image? , gdal_calc : fails with value 0?