1

I want to use ee.Algorithms.If. It gives different value by NDVI. I write code like this:

fsl=ee.Algorithms.If(ndvi1.gt(0.2),
                     0.92,
                     ee.Algorithms.If(ndvi1.lt(0.5),
                     0.99,
                     0.8));

I want to use this Polynomial. If NDVI is less than 0.2, the grid value is 0.9, if NDVI is greater than 0.5, the grid value is 0.92, if NDVI is between 0.2 and 0.5, the grid value is 0.91.

I get the error Cannot add an object of type <ComputedObject> to the map.

2
  • And what happens when you run this?
    – user2856
    Jun 4, 2020 at 6:04
  • Cannot add an object of type <ComputedObject> to the map.
    – Tiare chen
    Jun 4, 2020 at 7:46

1 Answer 1

1

One way is to use this:

//Suppose *NDVI* is your original NDVI
var NDVI2 = NDVI.expression('b(0) < 0.2 ? 0.9 : b(0) > 0.5 ? 0.92 : 0.91')

Update

Based on your comments, one way is:

var FSL= NDVI.expression('NDVI < 0.2 ? 0.92 : NDVI > 0.5 ? 0.99 : IndFV', {
'NDVI':NDVI,
'IndFV':fv.multiply(0.02644).add(0.96356)});

Hope it helps.

4
  • thank you ,is useful. But actually my last condition need NDVI raster join the calculation var NDVI2 = ndvi.expression('b(0) < 0.2 ? 0.92 : b(0) > 0.5 ? 0.99 : fv.multiply(0.02644).add(0.96356) how to use NDVI in this code
    – Tiare chen
    Jun 4, 2020 at 7:47
  • You're welcome. I don't understand your question. Please give me more details. Also providing your code might be useful.
    – HamiEbra
    Jun 4, 2020 at 8:00
  • I have a polynomial that calculates the surface emissivity FSL based on NDVI. When NDVI is less than 0.2, FSL=0.92; when NDVI is greater than 0.2 and less than 0.5, FSL=fv*0.02644+0.96356; when NDVI is greater than 0.5, FSL=0.99.
    – Tiare chen
    Jun 4, 2020 at 8:40
  • Thank you for your help
    – Tiare chen
    Jun 5, 2020 at 4:00

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.