Export Mask


I would like to export all relevant pixels as defined within the biophysical S2 data from SNAP. The processed data exports an LAI flag band. I would like to use this band to export all relevant pixels within the LAI dataset that have not been flagged as a GeoTIFF. Can someone describe how this could be completed?

Kind regards,


Hi Matt,

you can add a valid-pixel expression to the LAI band.
Right click on it and select properties.
There you can set the expression.
The expression should be

lai_flags == 0

Only if the lai_flags is the zero the lai value will be considered as valid.
If you want to be more specific and check only of specific flags you can use the masks.
For example:

!lai_output_too_high && !lai_output_too_low

1 Like

Thank you so much Marco,

That worked perfectly. I also wanted to write the band as a single band, so I used Band Maths instead by inserting the formula:

lai_flags ? NaN : lai

I also wanted to make sure that I am using the correct biophysical processor for lai for the data I am using. I am using atmospherically corrected level 2 Sentinel 2 S2MSI2A as a source dataset for the biophysical processor. In the help file, it contains a description of the processor and states it uses all 11 bands. I notice that there are actually 12 bands as band 8 contains 2, B8(842nm) and B8A(865nm).

From the source code I see that the algorithm uses only 8 of the reflectance bands (B3, B4, B5, B6, B7, B8A, B11 and B12) and the 4 geometry bands (view_zenith_mean, view_azimuth_mean, sun_zenith, sun_azimuth). And the 10m version uses the bands B3, B4, B8 and the geometry bands.

@MartinoF Can you update the documentation?

Hi @marpet,

The band used by each algorithm are documented in the algorithm description in the help (as you can see in the attached screenshot).

However there is a mistake and I accidentally ticked the B5 for the 10m algorithm. (that is already fixed in the master branch)


Ah, okay. I only had a look at the specific S2 page:

Also, in the column for the 20m net is a mistake. The band B8 is not used.

Thank you for reporting these errors, I will fix it as soon as possible!


PS: I will also link the algo documentation page from the 10m and 20m operator pages

Thank you Marco and Martino for all of your help. It is greatly appreciated.

Kind regards,


I would just like to confirm my process is one in which you would deem to be correct for the application of processing S2 data to LAI: first, I import Sentinel-2 L2A products which have been processed using Sen2COR (Sentinel-2 1C data processed to 2A Bottom of Atmosphere) using File>Import>Optical Sensors>Sentinel 2>S2-MSI L2A. I resample it to 20m using the Optical>Geometric>S2 Resampling Processor. Then I run the biophysical processor Optical>Thematic Land Processing>Biophysical Processor (LAI, fAPAR…)>Biophysical Processor S2. I then export 3 geotiff products from that data: a single band LAI, and 2 band raster with LAI and LAI flags and a single band raster with all flagged areas removed. To achieve the latter product I use the following code within Raster>Band Maths:

lai_flags ? NaN : lai

I believe this is the correct workflow but wanted to confirm this is what you would suggest as well.