You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documented behaviour. See https://gdal.org/programs/gdal_calc.html#gdal-calc
"""" Despite the datatype set using --type, when doing intermediate aritmethic operations using operands of the same type, the operation result will honor the original datatype. This may lead into unexpected results in the final result. """"
and
"""" In the previous example, beware that if A and B inputs are of the same datatype, for example integers, you may need to force the conversion of one of the operands before the division operation.
gdal_calc.py -A input.tif -B input2.tif --outfile=result.tif --calc="(A.astype(numpy.float64) + B) / 2"
""""
Expected behaviour and actual behaviour.
I expect this GDAL calc expression to work without warnings the same way it does when I break it down into two.
This returns
RuntimeWarning: overflow encountered in square
:gdal_calc.bat --overwrite --calc "(A-(0.2*B*7))**2" --format GTiff --type Float32 --NoDataValue -9999.0 -A C:\Users\asiddiqui\Desktop\gdal_square_issue\A.tif --A_band 1 -B C:\Users\asiddiqui\Desktop\gdal_square_issue\B.tif --B_band 1 --overwrite --outfile C:\Users\asiddiqui\Desktop\gdal_square_issue\C.tif
These two, which are the broken down version of the same expression, works fine without warnings.
gdal_calc.bat --overwrite --calc "(A-(0.2*B*7))" --format GTiff --type Float32 --NoDataValue -9999.0 -A C:\Users\asiddiqui\Desktop\gdal_square_issue\A.tif --A_band 1 -B C:\Users\asiddiqui\Desktop\gdal_square_issue\B.tif --B_band 1 --overwrite --outfile C:\Users\asiddiqui\Desktop\gdal_square_issue\C.tif
gdal_calc.bat --overwrite --calc "C**2" --format GTiff --type Float32 --NoDataValue -9999.0 -C C:\Users\asiddiqui\Desktop\gdal_square_issue\C.tif --C_band 1 --overwrite --outfile C:\Users\asiddiqui\Desktop\gdal_square_issue\D.tif
Steps to reproduce the problem.
Run the above expressions on the attached two tifs
gdal_square_issue.zip
Operating system
Windows
GDAL version and provenance
3.4.1
The text was updated successfully, but these errors were encountered: