Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to use the raster calculator in QGIS to combine a number of rasters. I want to calculate a mean, this is easy:

(raster_1@1 + raster_2@1 + raster_3@1) / 3

I then want to create a max. raster - i.e. for each pixel I want to compare raster_1, 2 & 3 and use whichever is the greatest of the three. According to the QGIS documentation I should be able to use the following code (modified from QGIS documentation example):

gt( raster_1@1, raster_2@1, raster_1@1 )

(All cells in raster_1 with value greater than (gt) the appropriate pixels in raster_2 will be replaced with the appropriate pixels from raster_1). I'd then have to repeat this for raster_3.

This doesn't work however as the raster calculator says the expression is invalid. What am I doing wrong? None of the examples of conditional statements provided in the QGIS documentation seem to work. I have tested this with .tif and .sgrd files and the same thing happens. I'm using QGIS 1.8 on a Linux machine. Thanks in advance.

share|improve this question
    
There used to be two raster calculators at some point. Are you sure you are using the one covered in the documentation? –  underdark Jan 22 '13 at 19:48
    
@underdark - yes I'm pretty sure I'm using the right one. I can only see one raster calculator in QGIS 1.8 and the picture of the GUI in the documentation is the same. Most of the commands work just not the conditional statements. –  Thomas Jan 24 '13 at 15:06
    
I checked the documentation again. There are no conditional statements mentioned. –  underdark Feb 6 '13 at 16:16

3 Answers 3

up vote 1 down vote accepted

So I managed to get this working in SAGA-GIS. The grid calculator (Modules > Grid > Calculus > Grid Calculator) works fine. I was able to make a raster consisting of the maximum values from all my polygons using the following code:

ifelse((a>b),a,b)
share|improve this answer

I think gt() is a function that is only available in RasterCalc plugin but not in the normal Raster Calculator that is available by default.

But this functionality can still be achieved using logical operators:

(a>b AND a>c) * a + (b>a AND b>c) * b + (c>a AND c>b) * c

Only one of the three terms will evaluate to 1, the others will be zero.

share|improve this answer

Refer to my post I think it is better to use the equation that is there (This coming a year later or so!)

Create A Maximum-Value Composite QGIS

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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