I am looking to create a Maximum-Value Composite raster in QGIS
I have three raster images: Oct 2012 Nov 2012 Dec 2012 All are in TIFF Format, Float32, EPSG:4326 - WGS 84
I want to stack these images, then on a pixel-by-pixel basis,examine each value, and retain only the highest value for that pixel location to create a Maximum-Value Composite (refer to http://en.wikipedia.org/wiki/Maximum-value_composite_procedure)
e.g.(these are made-up numbers for illustrative purposes):
Pixel in Row 205 and Column 106 will have three values: 90 75 100
I want to choose 100, then move to the next pixel and do the same. In the end I should have a final raster with maximum values only, a maximum value composite!
I am have QGIS 1.8.0 & 2.0.1, GRASS 6.4.3RC2 and SAGA 2.0.8 at my disposal.
-
agreed, there should really be simple aggregate functions like MAX, MIN.mitchus– mitchus2018年12月07日 12:32:24 +00:00Commented Dec 7, 2018 at 12:32
2 Answers 2
I think you can use QGIS raster calculator for this (Raster> Raster calculator...).
Having a rasterA, rasterB and rasterC layers, and assuming that you only have a band in each on of them, you can use a expression like this:
("rasterA@1" >= "rasterB@1" AND "rasterA@1" >= "rasterC@1") * "rasterA@1" +
("rasterB@1" > "rasterA@1" AND "rasterB@1" >= "rasterC@1") * "rasterB@1" +
("rasterC@1" > "rasterA@1" AND "rasterC@1" > "rasterB@1") * "rasterC@1"
The ("rasterA@1">= "rasterB@1" AND "rasterB@1">= "rasterC@1") parts, test id a certain layer value is bigger than the others will result in 0 or 1, whether the condition is satisfied or not. After the multiplication the result will have 0 or the value of the raster. Adding all the tree results will give you the hightest value.
There is probably a more elegant way to to this, but I think it will work.
From QGIS Raster Calculater Syntax, courtesy of @underdark:
(a>b AND a>c) * a + (b>a AND b>c) * b + (c>a AND c>b) * c
This answer worked for me in QGIS 2.0.1, I think the gt() method that was also referenced may only work for version 1.8, I didn't see that the RasterCalc plugin was available in 2.0.1.
-
I think this you are missing the a=b or a=c or b=c cases. And in any of those cases the result will be 0 instead of the maximum value. Imagine the following case a=2, b=2, c=1.Alexandre Neto– Alexandre Neto2014年02月14日 15:20:25 +00:00Commented Feb 14, 2014 at 15:20