I working to invert values of a one-band tif files (download sample).
If i use 254
it works:
$ gdal_calc.py -A ./shadedrelief.tmp.tif --outfile=whited.tmp.tif --calc="254*(A>180)"
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done
$ gdallocationinfo -valonly ./whited.tmp.tif 1 1 # we expect 254
254
$ gdal_calc.py -A whited.tmp.tif --outfile=inverted.tif --calc="255-A"
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done
$ gdallocationinfo -valonly ./inverted.tif 1 1 # we expect 1 (because 255-A = 255-254)
1
But the value 255
is troublesome:
$ gdal_calc.py -A ./shadedrelief.tmp.tif --outfile=whited.tmp.tif --calc="255*(A>180)"
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done
$ gdallocationinfo -valonly ./whited.tmp.tif 1 1 # we expect 255
255
$ gdal_calc.py -A whited.tmp.tif --outfile=inverted.tif --calc="255-A"
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done
$ gdallocationinfo -valonly ./inverted.tif 1 1 # we expect 0 (because 255-A = 255-255)
255 # <============================ THIS OUTPUT IS NOT EXPECTED.
As far as I know, RGBA range is [0-255]. So...
Why does gdal_calc fails with value 0?
Edit: and for some reason, the 254-based whited.tmp.tif
only has 2 type of pixels, so end final.tif also only has transparent [255,0] or black [0,255]. I expected a continuous gradation between the both.