I am a beginner in GEE. I am trying to create a model for SEBAL in GEE. I am stuck in a problem with LAI using SAVI. There is a problem with laio :(intermediate value).subtract is not a function

*function addLAI(image) {
    var laio = ee.Number(0.69.subtract(image.select('SAVI'))).log();
    var lai1 = laio.divide(0.59);
    var lai2 = lai2.divide(0.91).rename('LAI');
    return image.addBands(lai2)

What is the problem ?


1 Answer 1


Usually, the error messages "... is not a function" are caused by the use of a method that does not exist for a particular type of ee.Object or when the type of certain object is not clear for GEE and thus, needs a casting. In this case, the number needed a casting as ee.Number(0.69); however, since you want to generate an image with the subtraction of 0.69 and the SAVI value, you should instead use ee.Image.constant. Additionally, when defining lai2 you were calling a lai2 object that had not been defined; therefore, I assumed it should be lai1 instead of lai2. Here is the code that should perform the desired calculation.

function addLAI(image) {
    var laio = ee.Image.constant(0.69).subtract(image.select('SAVI')).log();
    var lai1 = laio.divide(0.59);
    var lai2 = lai1.divide(0.91).rename('LAI');
    return image.addBands(lai2);
  • Thanks for your response, sir. I used your code, however, the result of LAI is homogeneous( my study area is UAE). Is it ok? Jul 26, 2022 at 4:38
  • The result should not be homogeneous, unless there is no spatial variation of SAVI. I recommend first checking if SAVI is spatially homogeneous, and start debugging the script from there. Jul 26, 2022 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.