Preserving scaled reflectance values exporting GeoTIFF

I am facing an issue with exporting Sentinel-2B MSI L2A images from SNAP as GeoTIFF file while preserving the L2A scaled reflectance values.

When I open L2A image in SNAP, I can observe that it automatically scales it from 0 to 1 pixel values range. However, when exporting it as GeoTIFF, it is unsigned 16 bit integer instead of float 32 bit. Do I need to make some spade work before exporting it as GeoTIFF?

In GeoTiff only the raw data is stored which is uint16 for S2 data. Unfortunately, there is no standard to specify scaling factors in GeoTiff.
You can create new bands based on original ones by using the Band Maths.
This will apply the scaling factor and convert the data type to float32.
image
Make sure to uncheck the Virtual option.
Afterwards you can delete the original bands.
When you now save the data to GeoTiff the data is scaled.
This is annoying work in the GUI for many products. But you can you gpt to do this on a set of products.
Or you use an alternative file format like Netcdf4.


EOMasters_icon_60 Marco from EOMasters - Mastering Earth Observation

1 Like

@Marco_EOM May I make make use of graph bulider to minimize the time it requires to apply expression on individual band via Band Math and export the resultant bands stacked in a GeoTIFF file to export?
Thank you.

Yes, this is possible.
image
But the Band Maths in the Graph Builder can only calculate one band. So, you must merge them afterwards.

In a graph file you can define all bands and use it on the command line.
band_math_s2.xml (987 Bytes)
This is just an example. You need to add the other bands.

These guides might be helpful:
Creating a GPF Graph - SNAP - Confluence (atlassian.net)
Bulk Processing with GPT - SNAP - Confluence (atlassian.net)

Or you make use of Excel to simplify the processing setup:


EOMasters_icon_60 Marco from EOMasters - Mastering Earth Observation

2 Likes

Thank you for your prompt and effective solution to my problem. Your guidance has been instrumental in putting me on track. Its awesome to see examples and really useful links.

1 Like