-
Notifications
You must be signed in to change notification settings - Fork 3
Description
E84 is looking for feedback on how to properly handle the offsets in the Sentinel-2 data JP2 when they are converted to COGs for all new Sentinel-2 data with a processing baseline of 04.00 or higher.
This change introduced an offset that must be applied to the data and is explained here. Currently for the Sentinel-2 COGs, since Jan 2022, we apply the offset to the data. The offset is specified in the metadata, but currently has always been -0.1. The scale is 0.0001.
reflectance = scale*DN + offset
Going forward there are 4 options, ordered from worst to best, in my opinion.
1 - Leave the data as is
The COGs keep the same values as the JP2 files leaving the user responsible responsible for applying the offset. A serious issue with this is that when calculating simple band indices the scale of 0.0001 cancels out, e.g.,
NDVI = (nir - red)/(nir + red)
This is how a great number of notebooks and code out in the wild do this. If the offset is not applied the NDVI calculation becomes:
NDVI = (nir - red)/(nir + red - 2000)
which would break a large number of implementations. I would not recommend this.
2 - Apply offset as per the S2 Technical Guide
The recommended way for applying the offset is provided by ESA, however this as serious consequences.
With this method, any pixels 0 or less after applying the offset become equivalent to NODATA. While this seems reasonable at first because the pixel is invalid, the absence of collecting any data is not the same as measuring the surface and getting no meaningful signal. These are dark regions where the atmosphere has been overcompensated for. If they become 0 that tells the user there is no data rather than it being a dark object. This causes issues when visualizing as these dark regions would become transparent. For analysis this can cause gaps where there should not be. I would not recommend this approach.
3 - Apply offset, keep nodata=0
The current method used for the Sentinel-2 COGs maintains NODATA=0, but any values <-0 after applying the offset are set to a value of 1, which corresponds to a reflectance of 0.0001. The original nodata value locations are preserved. This indicates that data was there, but with a small value well below the noise level of the reflectance measurement.
This method would have virtually zero impact on any analysis of the data, however it is a change in the values, as is setting all negative data values to 1. It has the benefit of using the very common nodata value of 0. I find this to be an acceptable change.
4 - Apply offset, set nodata=65535
An alternative to the above is to change the nodata value to 65535, the max value for uint16. This has no chance to conflict with any valid data values which should not be higher than 11000 (reflectance ranges from 0-1.0). Then when the offset is applied is it clamped to 0, rather than 1.