SEN2COR wrong metadata in SAFE-compact - gdal sentinel-2 cannot find datasets


I’ve processed Sentinel-2 data with SEN2COR v2.3.0 and then tried to convert the output to geotiff with gdal 2.1.3 with the Sentinel-2 driver which states:

“Driver for Sentinel-2 Level-1B, Level-1C and Level-2A products. (GDAL >= 2.1). Starting with GDAL 2.1.3, Level-1C with “Safe Compact” encoding are also supported.”

The driver fails to identify datasets for SEN2COR processed L2A products. Looking at the MTD_MSIL2A.xml file, it seems to me that the content is wrong (at least in <L2A_Product_Organisation>).

We have contacted the gdal Sentinel-2 driver developers that confirmed that the format as implemented is messy.

Can this issue be addressed by the SEN2COR team?

I have the same problem.
SNAP 4.0 is not able to open any scene with a new naming convention (since Dec 2016). xml is simply not valid and does not work. It is occurs on a gradule as well as, dataset level.
Apparently, Sen2Cor 2.3.0 runs on these images (in a batch mode), but then obviously an outcome still has corrupted xml.

I would be grateful if someone could look into in.

Please try with updated SNAP5.0, as the older versions are not supported. We are planning to keep supporting 5.0 alongside later versions for a period in the future so upgrading to 5.0 is a rather safe move for operational users as well.

thank you. It was my obvious mistake.

Yes maybe SNAP 5.0 ignores the wrong format but the right approach here is to submit an issue on sen2cor to correct the format implementation of the S2 L2A products. The metadata is simply wrong and prevents gdal sentinel-2 driver from reading the datasets.

@mengdahl can you do that?

Hello Fabrice,

I’m not dealing with the optical side of SNAP but I can try and flag the developers for their comments @Nicolas @umwilm @marpet


Yes, I think @obarrilero, @kraftek and/or @umwilm should have a look at this.

Thanks @mengdahl and @marpet!

Hello! any updates regarding this?

Let me join @fabricebrito here :slight_smile:

@obarrilero @kraftek @umwilm, any updates on the matter? I’ve trying to open 2A products generated by Sen2Cor 2.4.0 with gdal 2.1.3 without success… :frowning:

I created a ticket for this issue. The implementation of a possible fix will be decided by the Sentinel-2 Level 2A Mission Performance Center.

Hi @umwilm!

Let us know how this will evolve.


Hi, can some say what the actual problem is?
@fabricebrito you started to describe it [quote=“fabricebrito, post:1, topic:5206”]
me that the content is wrong (at least in ).
but then you didn’t finish. :slight_smile:

@umwilm Couldn’t this be fixed in the next sen2core version? Sure, if the MPC is involved things take a while, but I think, this could be solved independent from the MPC, no? If this current output format is corrupt it should be corrected.
If done in the next version it would help at least those users who use sen2cor directly.

The problem is the L2A metadata. It’s not complete and thus gdal cannot build its internal model.

To reproduce:

  • generate a L2A product
  • inspect MTD_MSIL2A.xml

I can not see anything obviously wrong or things which are missing.

Attached two xml files for the same scene. One from SciHub the other processed by myself.
At least they are similar, except minor differences according to version update.

MTD_MSIL2A_sen2cor_v240.xml (52.4 KB)

MTD_MSIL2A_sciHub_v230.xml (52.8 KB)

Hi @marpet,

I’ve found the email exchange with the gdal S2 driver developer we got back in march this year:

 J'ai regardé l'exemple. Les métadonnées du nouveau format sont encore plus "funky" que le L1C "SafeCompact".
Par exemple dans MTD_MSIL2A.xml, on a une référence à <IMAGE_FILE_2A>GRANULE/L2A_T29SPA_A008857_20170303T111724/IMG_DATA/R60m/L2A_T29SPA_20170303T110941_TCI_60m</IMAGE_FILE_2A> mais aucun fichier ne commence par L2A_T29SPA_20170303T110941_TCI_60m ... Et il n'y a pas de produit TCI dans le jeu de données. Et les bandes effectivements disponibles ne sont pas listées.
Il y a également des fichiers _geo.jp2 quasi vides et invalides, à côté des véritables .jp2
J'ai l'impression que sen2cor fait des choses pas très propres... Ceci dit, tous les fichiers nécessaires sont là donc on doit pouvoir sans sortir.

Looking at your examples, it looks like it has been addressed. We will check and let you know.

Hi @fabricebrito,

Is this solved?
I converted 1C to 2A using sen2cor 2.4.0 and used GDAL 2.2.3 but still no sub-datasets are shown when calling gdalInfo for MTD_MSIL2A.xml.

Is there a way/workaround to convert L2A to geotiff?


Yes, you can open the output in SNAP and then resample it and save it as (Big)GeoTiff.
This might be of interest to you:

Hello @umwilm and @fabricebrito !

Is there any progress on this problem? I am using Gdal to read 2A products created with sen2cor 2.4.0 and I haven’t been able to find a way to read new files.

Thank you!