What I want to do sounds simple, but I am not sure, what the fastest option would be.
I have several thousand 4channel images for which I want to calculate the NDVI and then recode the images based on thresholds into several classes, e.g.
NDVI<0 --> class value 1
0=<NDVI<=0.4 --> class value 2
NDVI >0.4 -->class value 3
My approach would be to caclulate the NDVI image first using “otbcli_RadiometricIndices” first.
But how to perform the recode? Can I apply multiple conditions in BandMath/BandMathx?
to apply a condition with BandMath and BandMathX the syntax is
"logical expression ? value if true : value if false"
For example im1b1 < 0 ? 1 : 2
It is possible to chain this expression to apply several condtions at once, in your case, if im1b1 is the NDVI (for example computed by RadiometricIndices) :
You can also try to compute the NDVI directly in the BandMath Expression, but you’ll need to compute it twice (one for each expression), so I think it would be less efficient. (in an expression you can use ndvi(im1b1, im1b2) where b1 is the red band and b2 is the NIR band).