From 438a1fc39218ecfaaecf524d0c1ea40f069f2b82 Mon Sep 17 00:00:00 2001 From: Gwadaking Date: Wed, 1 Apr 2026 23:21:19 -0400 Subject: [PATCH] fix: add NDWI water mask to evalscripts (S2 + S3) to exclude land pixels --- .../src/Service/SentinelHub/SentinelHubClient.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/Service/SentinelHub/SentinelHubClient.php b/backend/src/Service/SentinelHub/SentinelHubClient.php index 6d2c621..cdda715 100644 --- a/backend/src/Service/SentinelHub/SentinelHubClient.php +++ b/backend/src/Service/SentinelHub/SentinelHubClient.php @@ -145,7 +145,7 @@ class SentinelHubClient //VERSION=3 function setup() { return { - input: [{ bands: ["B04", "B08", "B11", "CLP"], units: "REFLECTANCE" }], + input: [{ bands: ["B03", "B04", "B08", "B11", "CLP"], units: "REFLECTANCE" }], output: { bands: 1, sampleType: "UINT8" } }; } @@ -153,6 +153,10 @@ function setup() { function evaluatePixel(sample) { if (sample.CLP > 0.4) { return [255]; } // nodata : nuage + // Masque eau : NDWI = (Green - NIR) / (Green + NIR) — terre si <= 0 + const ndwi = (sample.B03 - sample.B08) / (sample.B03 + sample.B08); + if (ndwi <= 0) { return [0]; } + const lambdaRed = 664.5; const lambdaNir = 832.8; const lambdaSwir = 1613.7; @@ -178,16 +182,19 @@ EVALSCRIPT; //VERSION=3 function setup() { return { - input: [{ bands: ["B08", "B11", "B17"], units: "REFLECTANCE" }], + input: [{ bands: ["B06", "B08", "B11", "B17"], units: "REFLECTANCE" }], output: { bands: 1, sampleType: "UINT8" } }; } function evaluatePixel(sample) { + // Masque eau : NDWI = (Green B06 560nm - NIR B17 865nm) / (Green + NIR) + const ndwi = (sample.B06 - sample.B17) / (sample.B06 + sample.B17); + if (ndwi <= 0) { return [0]; } + const lambdaRed = 665.0; const lambdaRedEdge = 708.75; const lambdaNir = 865.0; - const ratio = (lambdaNir - lambdaRed) / (lambdaRedEdge - lambdaRed); // MCI : baseline interpolée entre Red et RedEdge const baseline = sample.B08 + (sample.B11 - sample.B08) * (lambdaNir - lambdaRed) / (lambdaRedEdge - lambdaRed);