6

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?

7

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.

1

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!

1

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^
  %FILE%\Run1_100yr10pc_030m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_060m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_090m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_120m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_180m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_270m_EX_H_Max.flt^
  %FILE%\Run1_100yr10pc_360m_EX_H_Max.flt^
  -out %FILE%\CriticalDuration\Run1_100yr10pc_CritDur_H_EX

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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