I have a function which assigns a score depend on the value of a band, which I then map to an image collection.
However, in some cases, I have null values, where no value is given. In these cases I'd like to convert the null values to 0. I tried to set null values as zero in the code, but I'm getting an image error. My new code, with the extra line is below.
function currentHS_function(image){
var currentHS = image.expression(
"(b('current') < 0.13) ? 1.0" +
": (b('current') > 0.15) ? 0.0" +
": (b('current') = null) ? 0.0" + // new line - set null values as 0
": -50.0*current + 15.0/2.0 ",
{"current" : image});
return currentHS;
}
// apply heath score function to image collection
var currentHS_collection = currentSpeed.map(currentHS_function);
Best Answer
One thing you can do is to unmask the image using a proxy value before the expression and then catch that proxy value:
In this case -999 is the proxy value, but you can use one of your own