Hi SentinelHub Users,
I have 3 Sentinel-2 L2A images from distinct sources: SentinelHub API, AWS and Copernicus CDSE.
The images from AWS and CDSE shows exactly the same radiometric values and the pixels are in the exact same position (no image distortions or smoothness), same pixel size (10.0m).
The image from SH API has little differences (smoothness appearance, different pixel size (10.002m), pixel values a little off the CDSE reference, and most of all shows some distortions, probably from CRS conversions or other hidden resampling steps.
Discarding radiometric offsets or re-scales, there is any way to get the exact image from SH-API, as we get from AWS/CDSE?
Files: https://file.io/95vAfiFV6POe
Files date: 2023-05-09
i’m using the following code:
# Download
input_task_L2A = SentinelHubInputTask(
data_collection=DataCollection.SENTINEL2_L2A.define_from(
name="s2l2a", service_url="https://sh.dataspace.copernicus.eu"
),
bands=l2a_bands,
bands_feature=(FeatureType.DATA, "Sentinel2_L2A"),
additional_data=[(FeatureType.MASK, 'SCL')],
resolution=10,
maxcc=maxcc,
time_difference=time_difference,
config=config,
max_threads=max_threads,
bands_dtype=np.uint16,
upsampling='BICUBIC',
downsampling='BICUBIC'
)
# VALIDITY MASK
# Validate pixels using SentinelHub's cloud detection mask and region of acquisition
add_sh_validmask = SentinelHubValidData('IS_VALID')
# FILTER OUT CLOUDY SCENES
# Keep timestamps with > 95% valid coverage
valid_data_predicate = ValidDataFractionPredicate(1-maxcc_roi)
filter_task = SimpleFilterTask((FeatureType.MASK, 'IS_VALID'), valid_data_predicate)
# SAVE tifs
save_tiffs_l2a = SaveToTiffs_L2A()
workflow_nodes = linearly_connect_tasks(input_task_L2A, add_sh_validmask, filter_task, save_tiffs_l2a)
workflow = EOWorkflow(workflow_nodes)
result = workflow.execute(
{
workflow_nodes[0]: {"bbox": bbox, "time_interval": time_interval}, # "geometry": geometry},
workflow_nodes[-1]: {"folder": sentinel2_path}
}
)
class SaveToTiffs_L2A(EOTask):
""" Threshold mean NDVI mask """
def execute(self, eopatch, folder):
for i, timestamp in enumerate(eopatch["timestamp"]):
task = ExportToTiffTask((FeatureType.DATA, 'Sentinel2_L2A'), folder=folder, date_indices=[i], crs=32629, compress='None')
# task = ExportToTiffTask((FeatureType.DATA, 'Sentinel2_L2A'), folder=folder, date_indices=[i], compress='None')
task.execute(eopatch, filename=f'Sentinel2_L2A_{timestamp.strftime("%Y-%m-%d")}')
task = ExportToTiffTask((FeatureType.MASK, 'SCL'), folder=folder, date_indices=[i], crs=32629, compress='None')
#task = ExportToTiffTask((FeatureType.MASK, 'SCL'), folder=folder, date_indices=[i], compress='None')
task.execute(eopatch, filename=f'SCL{timestamp.strftime("%Y-%m-%d")}')
return
Thanks for any insights on this question.