How to apply quality mask with Graph builder


I’am starting with snap and graph builder. I want to automatize this process:

  • reading Meris image (N1)
  • with band math, excluding algal2 values affected by this mask ‘invalid_algal2_tsm_ys’
  • write the output in new_band
    This process works well on snap but with graph builder it gives bad result.

Thank you in advance

can you please explain what you mean by “bad result”?


I mean that there is anomaly in pixel values of output band. For example, even if cloud and land pixels aren’t concerned by the band math expression (which is if invalid_algal2_tsm_ys then -9999 else algal_2) , their values changed after running the xml script. But all things work well when I execute the same band math expression in snap.

Thank you in advance.


How big is the difference after you have processed the data? Can you share some screenshots and/or numbers?

mask-issue.docx (377.8 KB)

I attached a word file to illustrate my issue. You can see that cloud values were NaN and after apply the band math expression which has no relation with cloud, their values became float number (0.05…).


The difference is that within SNAP the valid pixel expression of the source is considered.
If you change your expression to

if invalid_algal2_tsm_ys then -9999 else (if l2_flags.WATER then algal_2 else -9999)

and set as no-data value -9999 then you should get the same result.

Thank you very much.

I got the same result as in SNAP, I understand the trick.

Thank you Marpet for your help.