SNAP using S2Agri atmospheric corrections

Hello jofrisch,

I’m responsable to the developpement of this converter.
This converter permits to:

  • convert L2A products from THEIA format to ESA format, and
  • convert L2A products from MAJA/MACCS/S2AGRI format to ESA format
    The inputs of this converter must be L2A products at MAJA/MACCS/S2AGRI/THEIA format and the output will be L2A products at ESA format.
    Your log seems to indicate that the input is at ESA format (S2A_MSIL2A_20170214T080021* nomenclature). Is it the case?

However, is it possible to continue this discussion by mail?
If yes, please contact us at the mail address indicated at the webpage https://theia.cnes.fr/atdistrib/rocket/#/contact

Hello CDes,
Just sent you an email.
To answer your question my input is indeed a S2A_MSIL2A_20170214T080021* product.
Some context: it’s the result of Sen2Agri’s L2A algo: MACCS. So from what I understand it’s supposed to be a MACCS format.
We can continue this discussion via emails.

Hello jofrisch and CDes,

please don’t hesitate to report your discussion on this forum. I can be interesting for the community.
I will also test the converter soon and will report my results.

Thanks

Hi,

just tested with a MUSCATE product as input.
It ran well and generated jp2 files and a XML file (attached).
However, SNAP cannot open it.
MTD_TL.xml (610.4 KB)

Hi @olivegak971,
I am having the same problem as you, I 've tried to create the .xml to make snap read the file, but without success so far.

On your previous question: we discussed the bug reported above, which is now fixed, and some naming in the tile that should be corrected in a coming update of the github repo. :slight_smile:

Hi all, and Snap developers.
There are a lot of fields in the xml header file of a Sen2cor product. Is there a list of those which are used and read by Snap ? We could then only take care of those ones… We should be able to manage with the reading piece of source code within Snap, but could you find it for us ?

Best regards,
Olivier

Hi @OHagolle,

I could take a look and see what is missing, but it would be easier for me if you can share one example of a converted product.

Regards

Hi Omar, thanks for answering !
@olivegak971 provided one, just above. You can see that it lacks about everything…
That’s why it seemed easier to start from the reading interface of SNAP
Olivier

Actually, there should be a format specification. Which the reader and the writer consider. Think about a third party application (GDAL, Envi) which wants to read the data. If you don’t follow the specs or only satisfy SNAP they are lost.

In the S2 reader of SNAP, we also check the folder structure of the product, it is not enough the metadata file.

Hi Marco,

Of course we have a format specification. Envi, Snap and GDAL are welcome to use it:

Here we are just trying to help some Snap users who would like to use our products providing a converter, with money and time constraints …
Olivier

2 Likes

Hi,

I have made some tests and it seems that there are some things to modify in the converted product to be compatible with the Sentinel-2 reader in SNAP:

1 - Create an empty folder “QI_DATA” at the same level than “IMG_DATA” folder
2 - Modify the metadata xml file:
2.a) The item HORIZONTAL_CS_CODE should contain, before the code, “EPSG:”

2.b) The tag “detector_id” should be replaced by “detectorID”

2.c) The bandID should be an integer from 0 to 12 (in the example, it is used 8A, which is not valid)

2.d) The element TILE_ID_2A should follow the pattern:

(see https://earth.esa.int/web/sentinel/user-guides/sentinel-2-msi/naming-convention)

for example:

I think that is all, if you have still any problem, please tell me.
Regards

1 Like

Thanks a lot for this precious help, Omar.
Olivier

Hi everyone,

As Jonathan, I would like to compute FAPAR in SNAP based on L2A products coming from Sen2Agri. Is there any step forward in SNAP to work with S2A images without having to adapt the L2A from S2A (update metadata XML file…)?
Is the last message from obarrilero still the best workaround?

Thank you for your help,
Christophe

Hi Christophe,

I made a little tutorial for using a MUSCATE product as input for the biophysical processor, I copy it below.

Currently the Muscate reader is in development, but there is a workaround to be able to run the biophysical processor by preprocessing the MUSCATE images within SNAP. The objective is to get a product with the bands needed by the operator at identical resolution (B3, B4, B5, B6, B7, B8A, B11, B12, view_zenith_mean, view_azimuth_mean, sun_zenith and sun_azimuth).

  1. Open all the needed reflectance bands in SNAP, all of them should be at 20m except B3 and B4, which are at 10m.

  2. Resample the bands to the desired resolution. In this example, the desired resolution is going to be 20 m, so we have to resample only the B3 and B4.
    Menu->Raster->Geometric Operation->Resampling
    In the resampling parameters, we choose ‘By pixel resolution (in m): 20”

  1. Create a product containing all the reflectance bands by using “Band Math…”
  • We choose a master product between the current opened products, in this example we are going to use the B3_resampled

  • Compute reflectance: if we see the pixel values of any band, the values are not the reflectance, they have to be divided by 10000 to get the reflectance. (This could be different depending on the input?) To carry out the conversion, using BandMath, we create a new band (no virtual) by dividing the band by 10000. We call it B3, and we define its wavelength in nm: 560

  • Add the rest of the band to this master product using Band Math for each band. Remember to select Non-Virtual, to introduce the corresponding wavelength and to divide by 10000 to get the reflectance.

  1. Add the angle bands:
  • Open the equivalent L1C or S2A in format SAFE in SNAP to be able to get the angle bands.
  • Resample the product to the desired resolution
  • Using band math, add the following bands (with identical name!!):
    i. view_azimuth_mean
    ii. view_zenith_mean
    iii. sun_azimuth
    iv. sun_zenith

  1. Save the master product in BEAM-DIMAP (if you want)
  2. Make a subset to the region of interest (if you want)
  3. Run the biophysical processor Menu->Optical-> Thematic Land Processing -> Biophysical Processor…

I hope this helps until the muscate reader is ready.

2 Likes

Hi Olivier,

I have a question regarding the S2A L2A product specification you have provided. I have some sen2agri products which don’t seem to fit the specifications. They have a CLD instead of an CLM file and also the bit coding inside the file seems different. Do I have files processed with an older version?

The information from the HDR file is as follows:
MACCS_L2_NOMINAL_CHAIN
<Creator_Version>5.1.5</Creator_Version>

Thanks in advance,
Jan

Hi Jan,
Sen2Agri has its own file format, with minor changes. Please ask the Sen2agri support.
There is a forum, (which was not operational this morning) on Sen2agri site (http://www.esa-sen2agri.org/), and you might also ask questions on the github page : https://github.com/Sen2Agri/Sen2Agri-System

Best regards,
Olivier

Hello.

The Sen2Agri forum moved to http://forum.esa-sen2agri.org. If you had an account on www.esa-sen2agri.org, that will do to access it.

Cosmin.

Hi Omar

thanks for your tutorial.
In order to include the angles bands, do I have to download the L1C product as well (in addition to the Muscate L2A product) ?
Or can i retrieve those bands separately, or generate them ?

I hope the “double download” is not mandatory because my bandwidth is quite low.

Hy Omar
I asked you some time ago how to launch the biophysical processor; and we agreed on the fact to erase all the masks

Is it no longer necessary ? : it seems you do not include band masks
This tutorial is excellent ,as usual ,

I have another problem :I try to export the LAI file in geotiff file format and I get somthing unreadable : very whitish
Have you any solution to export files that could be opened in ,say GrassGis ,and not all white ?

Many thanks
Bruno

1 Like