[gdal-dev] Calculations with uint16 rasters

Alexandre Neto senhor.neto at gmail.com
Wed Sep 18 02:00:51 PDT 2019


I am new to this list so sorry if this has ever been asked or discussed.

I am using two sentinel bands in gdal_calc. they are in jp2 format and
uint16. I was surprised that subtracting one for the other (A - B) was
giving me strange results.

gdal_calc.py --calc "(A-B)" --format GTiff --type Float32 -A
--A_band 1 -B
--B_band 1 --outfile

The result only returns positive integers, and the integers scale seems
shifted to accommodate the negative values to something above 0.

Strangely the fix comes by multiplying the values by 0.1. So (A*1.0 -
B*0.1) works as expected.

Is this a known issue? Is it the expected behavior?


Alexandre Neto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190918/ab0eee3d/attachment.html>

More information about the gdal-dev mailing list