After I average two raster files (singleband gray, initial size ~700MB each) through QgsRasterCalculator() with formula "Raster1@1/2 + Raster2@1/2" the size of the resulting file is 2.9GB.

Is there any possibility to keep the filesize somehow lower by modyfing something? Switching to some external toolbox?

  • Please edit the question to contain the pixel depth of the resulting raster.
    – Vince
    Jan 29, 2016 at 6:55
  • 1
    Could you send the output of gdalinfo command for the input and output file? May be the result raster contains float numbers, not bytes. gis.stackexchange.com/questions/178181/… may help, too.
    – Zoltan
    Jan 29, 2016 at 7:16

1 Answer 1


There are 2 main reasons why a two raster with the same extent and the same pixel size have different size :

1) the pixel depth

2) the compression

in your case, dividing by 2 might produce a float while your input is integer (e.g. unsigned 8bit). Furthermore, the input could be compressed while the output is not. For full control on the output type, you could use gdal_calc or OTB bandMath (the latter is available through your QGIS interface). For the pixel depth, you can specify int() in the rastercalculator.

You can also use gdal_translate (or raster > conversion > translate in the QGIS interface) to convert your output after processing with -ot Byte for outputs in 0-255 and minimum size, -co COMPRESS=LZW for the compression (LZW is a type of compression given as example here, there are others depending on your needs)

For large raster, as mentioned by @Kersten, tiling is also recommended -co TILED=YES

Those options can be used with any gdal command (you can add them manually in the QGIS interface) or with the extented filename of the OTB application e.g. "yourfilename.tif?&gdal:co:COMPRESS=LZW&gdal:co:TILED=YES"

  • 1
    Tiling often has a significant impact, especially used together with compression so I'd also include -co TILED=YES.
    – Kersten
    Jan 29, 2016 at 10:25

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.