I just made a simple subtraction between two raster layers and got the error:

Traceback (most recent call last): File "C:/Users/user/.qgis2/python/plugins\raster_transparency\rastertransparency.py", line 150, in layerChanged maxValue = int(stat.maximumValue) OverflowError: cannot convert float infinity to integer

Both layers are Geotiff 32 bit pixel depth and floating point pixel type.

Is this a bug in the raster calculator or does anyone have suggestions to why I cannot subtract the two layers? Running QGIS 2.10.1

  • In your output layer you have an infinity symbol after these calculations. Python tries to perform int(infinity) ant it can't be done.
    – dmh126
    Commented Nov 17, 2015 at 12:04
  • hmm okay, thanks for your answer! Is that something I can change manually? I also just found out that QGIS say the layer min-max is -1.66 - 392.71 gdal info say its -6.7 - 562 (which is right). I dont understand wy QGIS show the wrong value. If I load the raster to ArcMap the right values are shown
    – geogrow
    Commented Nov 17, 2015 at 12:12
  • Ok so about QGIS displaying wrong Min/max is bc it calculates by default is 2% - 98%, see the 'Cumulative count cut' option in the 'Load min/max values' section of the dialog box.
    – geogrow
    Commented Nov 17, 2015 at 12:20
  • In C:/Users/user/.qgis2/python/plugins\raster_transparency\rastertransparency.py you can try to manually change this line maxValue = int(stat.maximumValue) to something like that maxValue = stat.maximumValue. I think it is qgis function bug, wrong band statistics.
    – dmh126
    Commented Nov 17, 2015 at 12:33
  • Thanks for your suggestion! I tried what you said. Replaced maxValue = int(stat.maximumValue) with maxValue = stat.maximumValue. Did the same with the minimumValue. Unfortunately it came back with the same error but displaying maxValue = stat.maximumValue instead. I know some people in my office has worked with the same tif file and done some raster calc with it in QGIS so I wonder if I have a bug in my program
    – geogrow
    Commented Nov 17, 2015 at 13:34

1 Answer 1


I was not able to use the built in raster calculator. However using the SAGA raster calculator in the processing toolbox did the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.