Monday, 13 July 2015

Creating Maximum-Value Composite using QGIS?


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.



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...