Hi William.
This is the body of Sentinel Hub Request:
{
"input": {
"bounds": {
"bbox": [
4681903.305609,
1981958.981233,
4686951.734307,
1986431.434369
],
"properties": {
"crs": "http://www.opengis.net/def/crs/EPSG/0/3035"
}
},
"data": [
{
"dataFilter": {
"timeRange": {
"from": "2020-10-04T00:00:00Z",
"to": "2020-10-04T23:59:59Z"
}
},
"type": "sentinel-2-l2a"
}
]
},
"output": {
"width": 501.2608418544286,
"height": 420.7542793512827,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/tiff"
}
}
]
},
"evalscript": "//VERSION=3\n\n // Initialization of the setup function\n function setup() {\n return {\n // List of all bands that will be used in the script\n input: [\n {\n bands: [\"B04\",\"SCL\"],\n units: [\"reflectance\", \"DN\"] // \"DN\" for Digital Numbers, \"REFLECTANCE\" for reflectance\n }\n ],\n // Definition of the output band\n output: { \n bands: 1,\n sampleType: \"FLOAT32\" // \"UINT16\" for \"DN\", \"FLOAT32\" for \"reflectance\" \n },\n mosaicking: \"ORBIT\"\n };\n }\n \n // Function that returns only valid pixels\n function isValid(sample) {\n var scl = sample.SCL;\n if (scl === 3) { // SC_CLOUD_SHADOW\n return false;\n } else if (scl === 9) { // SC_CLOUD_HIGH_PROBA\n return false;\n } else if (scl === 8) { // SC_CLOUD_MEDIUM_PROBA\n return false;\n } else if (scl === 7) { // SC_CLOUD_LOW_PROBA / UNCLASSIFIED\n return false;\n } else if (scl === 10) { // SC_THIN_CIRRUS\n return false;\n } else if (scl === 11) { // SC_SNOW_ICE\n return false;\n } else if (scl === 1) { // SC_SATURATED_DEFECTIVE\n return false;\n } else if (scl === 2) { // SC_DARK_FEATURE_SHADOW\n return false;\n }\n return true;\n }\n\n // Function to create a composite with the most recent valid pixels\n function evaluatePixel(samples) {\n // Sort samples with timestamps in descending order\n samples.sort(function(a, b) {\n if (a.metadata && b.metadata && a.metadata.timestamp && b.metadata.timestamp) {\n return b.metadata.timestamp - a.metadata.timestamp;\n }\n return 0;\n });\n var composite;\n for (var i = 0; i < samples.length; i++) {\n var sample = samples[i];\n if (isValid(sample)) {\n composite = sample.B04;\n break; // Break the loop after finding the first valid sample\n }\n }\n return [composite];\n }"
}
I am also attaching the images obtained both from SentinelHub and CDSE
SentinelHub_image.tiff (483.4 KB)
CDSE2.tiff (485.8 KB)