Hi Forum,
I am new to using SentinelHub to automate vegetation index. I have a custom script in the Evalscript to calculate NDRE. My code is as below:
//VERSION=3
function setup() {
return {
input: ["B08", "B05", "dataMask"], // Ensure correct band names
output: [
{
id: "default",
bands: 4, // Output bands for the color visualization
},
{
id: "index",
bands: 1, // Output band for index value
sampleType: 'FLOAT32'
},
{
id: "eobrowserStats",
bands: 2, // Output bands for eobrowserStats
sampleType: 'FLOAT32'
},
{
id: "dataMask",
bands: 1 // Output band for the dataMask
}
]
};
}
function evaluatePixel(sample) {
// Convert to reflectance if needed
var b08 = sample.B08 / 1000;
var b05 = sample.B05 / 1000;
// Calculate NDRE
var ndre = (b08 - b05) / (b08 + b05);
// Check dataMask value
const indexVal = (sample.dataMask === 1) ? ndre : NaN; // NDRE index without no-data values
// Reclassify NDRE and assign colors
var imgVals;
if (!isNaN(ndre)) { // Ensure NDRE is a number
if (ndre >= 0.6 && ndre <= 1.0) {
imgVals = [0, 0.498, 0, sample.dataMask]; // Color for NDRE 0.6 - 1.0 (Very Healthy)
} else if (ndre >= 0.4 && ndre < 0.6) {
imgVals = [0, 0.745, 0, sample.dataMask]; // Color for NDRE 0.4 - 0.6 (Healthy)
} else if (ndre >= 0.2 && ndre < 0.4) {
imgVals = [0.996, 0.996, 0, sample.dataMask]; // Color for NDRE 0.2 - 0.4 (Moderately Stressed)
} else if (ndre >= -1 && ndre < 0.2) {
imgVals = [0.745, 0, 0, sample.dataMask]; // Color for NDRE -1 - 0.2 (No Vegetation)
} else {
// Use #3275a8 as the default color (for NDRE outside the specified ranges)
imgVals = [0.196, 0.459, 0.658, sample.dataMask]; // Equivalent to #3275a8
}
} else {
imgVals = [0.196, 0.459, 0.658, sample.dataMask]; // Default color for NaN values
}
// Return the 4 outputs and define content for each one
return {
default: imgVals,
index: [indexVal],
eobrowserStats: [indexVal, 0], // No cloud value
dataMask: [sample.dataMask]
};
}
My problem is, does the resampling between these 2 bands have been automated to change Band 5 from 20m to 10m resolution? Currently working on visualizing NDRE using Band 8(10m) and 5(20m). The output of the code is quite different from what we’ve calculated manually on ArcGis Pro. Is there any solution or something I’m missing? Thank you in advance!
Summary
This text will be hidden