Skip to main content

While trying to customize NDVI coloring, we got a trouble not to visualize accurately as returned from evaluatePixcel function. When simplified as follows, we finally found a specific point that might bring a problem. When returned code[0] from evaluatePixel(), the preview becomes a perfect yellow; however, code[1] brings absolute white. There is only a little difference between 2 arrays. Why is this happened on code[1]? How could we get a correct color from code[1]?

We are in great trouble for this. What we need is to make a precise customization according to NDVI value from B04 and B08. Thank you for the quick help.


//VERSION=3


function evaluatePixel(samples) {

let code = [[255,255,0], [255,255,1]];

return code[0];

}


function setup() {

return {

input: [{

bands: [

“B04”,

“B08”

]

}],

output: {

bands: 3

}

}

}

Specify also the appropriate sampleType of the output. For pngs that would be UINT8 (values ranging from 0 to 255).


//VERSION=3

function evaluatePixel(samples) {
let code = [[255,255,0], [255,255,1]];
return code[0];
}

function evaluatePixel(samples) {
let code = [[255,255,0], [255,255,1]];
return code[1]
}

function setup() {
return {
input: [{
bands: [
"B04",
"B08"
]
}],
output: {
bands: 3,
sampleType: SampleType.UINT8
}
}
}

Thank you! It is solved!


Reply