I have 40 overlapping raster grids (derived from flood modelling software) that I want to combine in such a way so as to retain only the maximum value in any of the given rasters at each grid location, in a new raster grid.

Is there any application or command using the QGIS suite that would permit this without being unwieldy?

5 Answers 5


Give the SAGA "Mosaik raster layers" tool a go:

From the 'Processing' menu, choose 'toolbox' - type 'mosaic' in the search box to reveal the "Mosaik raster layers" tool:

enter image description here

Launch the tool, choose your inputs, and note the "Overlapping Areas" option, which has a 'maximum' parameter:

enter image description here

If you're looking for something more automated, the GDAL tools will help.

  • 2
    This tool doesn't seems to work with multi-band rasters (e.g. truecolor landsat) Feb 19, 2020 at 22:58
  • 1
    Doesn't work well when mosaic DEMs either. I got pretty strange w/ zigzag surface DEM
    – Tung
    Mar 12, 2020 at 4:29
  • I think you have to make sure your DEM's are in the same projection (EPSG) ? Dec 30, 2022 at 16:39

Use raster calculator from gdal (toolbox). Here you need to add the different layers and which band you want to combine. Use as a function maximum(A,B) (if you have 2 layers). WORKS!


Copy of this answer: https://gis.stackexchange.com/a/425197/92995 In QGIS/processing, use the GRASS tool "r.series". As "Aggregate operation" choose "maximum"

The tool also conveniently can be set to ignore values above/below set values (useful in eliminating a NULL value of e.g. -9999, so it does not affect the results).

I think raster have to be same CRS, but can be different extend and different resolution.


My response is outdated, but I was unable to find an acceptable answer posted elsewhere, and unfortunately, for unknown reasons the SAGA-based solution above was not working for me. So, another option you could consider is to use GDAL. Specifically the tool gdalbuildvrt http://www.gdal.org/gdalbuildvrt.html

As long as your set of input rasters have the same a) format, b) projection, c) cell size, and d) extent, then you can use the option "-r maximum" of gdalbuildvrt.py in the command line. If you have OSGeo4w shell installed, open that, and the syntax would be (assuming your are using .tif files)...

gdalbuildvrt -r maximum -input_file_list [your_list_of_raster_filepaths.txt] output_raster_name.tif

In windows, an easy way to derive a list of raster files for input in the -input_file_list option above is...

  1. Open a cmd window
  2. Navigate to the folder containing your rasters
  3. Type the following command...

    dir /b /s *.tif>filelist.txt

I had the same problem for a set of 12 rasters (GeoTiff), where I needed the maximum value from all overlapping rasters stored in a single grid. Unfortunately, I was not able to achieve this using SAGA Mosaic tool, nor with gdal_calc.

Good luck!

  • -r maximum is not an available option for buildvrt, as seen in documentation: -r {nearest (default),bilinear,cubic,cubicspline,lanczos,average,mode}
    – Theo F
    Feb 20, 2020 at 18:28
  • nevertheless -r max worked for me.
    – Julian
    May 14, 2020 at 9:13
  • I just used this and two 1.5 Gb files merged to become almost 14 Gb. Is that...expected?
    – hmnoidk
    Jan 11, 2022 at 16:56
  • If source files were compressed and you created an uncompressed file then it is expected. New users are often unaware of compression and ballooning file sizes make confusion.
    – user30184
    Mar 23, 2022 at 21:35

If they all have the same extent you could try the TUFLOW utilities to envelope the grids. The tool also outputs a second grid which can be colour coded to show which of your 40 grids produced the highest level a each location.

More info here: https://wiki.tuflow.com/index.php?title=ASC_to_ASC#Maximum

I have used this tool in the past for grids other than TUFLOW. It works for asc and flt formats as long as the extent of all the grids is the same. I typically list all the files in a text file (type dir > filename.txt in cmd) and then build the batch commands around this to look something like below. The ^ on the end of the line allows you to list your grids rather than have in one giant long line.

set EXE=C:\TUFLOW\Utilities\asc_to_asc\asc_to_asc_w64.exe
set FILE=Y:\FilePathToGrids\MaxGrids
md %FILE%\CriticalDuration\
Call %EXE% -b -max^
  -out %FILE%\CriticalDuration\Run1_100yr10pc_CritDur_H_EX

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.