The term "band math" always makes me think of RSI's second "flagship" product ENVI. If you are indeed an ENVI user, be aware that RSI's User Forum website has a separate forum for ENVI questions.
I give here, though, a general solution for masking let's say a 2D signed 16-bit image band, where the user wishes to mask out all values between -9999 and 0:
maskValue = 0
maskedImg2D = origImg2D
maskedImg2D[where(maskedImg2D le 0)] = maskValue
The above is probably the most traditional (or intuitive) way to mask. The below, probably more efficient, code would produce the same result:
maskedImg2D = origImg2D > 0
That one line sets all values that are not gt 0 to 0, while leaving untouched all values that are already gt 0.
James Jones
|