0

I've got 150 monoband raster files (with 0 and 1 values ) and I want to "fuse" or stack them as I would do it with the raster calculator : A+B+C.....

I can manage to create a VRT file containing 150 bands but how would I transform it to a monoband TIFF with values going from 0 to 150 ?

2
  • One option is to use gdal_calc python script gdal.org/programs/gdal_calc.html but it is written to use input bands A-Z so that it can't take 150 inputs. I guess it is possible to edit the script to accept more inputs.
    – user30184
    Apr 27, 2020 at 10:25
  • Yep ,indeed . a solution for me might be to use it for each .tif creation (rather than waiting having my 150 tiles calculated). But is it possible to flatten each band of a .vrt into one by summing all ?
    – FabKzo
    Apr 27, 2020 at 12:17

1 Answer 1

2

In QGIS, my suggestion is to use SAGA Rasters sum tool (which is in the Processing Toolbox > SAGA > Raster Calculus.

Processing 150 raster files would require intensive computing;

  • Put your raster files in a folder / directory.
  • Restart QGIS first (or at least avoid displaying your raster layers on QGIS canvas).
  • Start Rasters sum tool.
  • Click on the ... button of Grids selection, then click on Add Directory... and select the folder.

enter image description here

I have not done this with 150 files... you may have to separate them into several folders and repeat the process.

1
  • Thanks, Indeed I use QGIS ; tested but this takes a very very (too) long time. I wonder if there a way to make it with imagemagick ...
    – FabKzo
    Apr 27, 2020 at 9:44

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.