[GIS] Combine overlapping rasters in gdal_calc.py, taking the maximum value from each pixel

gdalraster

I want to combine 3 overlapping rasters to create 1 raster. Each have the same dimensions, resolution and CRS. I want to populate the new raster with the maximum value from each of the layers. However, when I use gdal_calc.py the output only writes two of the rasters.

Any ideas?

gdal_calc.py -A ./EXTENT_30_OS_clipped_nodata.tif -B ./EXTENT_100_OS_clipped_nodata.tif -C ./EXTENT_1000_OS_clipped_nodata.tif --calc="maximum(A,B,C)" --outfile=./EXTENT_1000_100_30_OS.tif --type=Byte --NoDataValue=-9999 --overwrite

Best Answer

gdal_calc.py as stated in documentation:

http://www.gdal.org/gdal_calc.html

uses numpy array functions, in this case numpy.maximum, which is specified here:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.maximum.html

It says you can use only 2 parameters. So your calculation expression for three grids must look like this:

maximum(maximum(A,B),C)