3

I want to apply an algorithm to calculate the clorophyll-a concentration of a reservoir using Sentinel 2.

To do this I need to create a mask using Sentinel's 2 band 11(infrared) to separate the water pixels from pixels with larger reflectance values than the water.

This is the algorithm:

(If B11 <=0.05 then 109.17*((1/B4-1/B5)*B6+ 19.03 else 0)

but I can't use if and else in QGIS.

2
6

Since it is a raster layer you should use the Raster Calculator. It is a bit different then the Field Calculator described by the other answer and comments. The expression should be something like this one:

("raster@11" <=0.05) * (109.17*((1/"raster@4"-1/"raster@5")*"raster@6"+ 19.03) + ("raster@11" >0.05) * 0

where "raster" is the name of your sentinel raster layer and @11 or @5 is the band number. The principe is as follows:

(condition) * value_if_true + (Else condition) * ElseValue

See also https://docs.qgis.org/3.10/en/docs/user_manual/working_with_raster/raster_analysis.html#raster-calculator

4

You can use CASE...WHEN in an expression:

CASE 
 WHEN B11 <=0.05 THEN (109.17*((1/B4-1/B5)*B6+ 19.03
 ELSE 0 
END

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.