1

I have a list of dates and EVI values and extracted the EVI values to find the highest one. However, when I iterate through the list, it won't print anything for the maxEViValue (every value in datatable is higher than -100). What's the problem?

This is my code:

// Initialize a variable to store the maximum EVI value
function findmaxEVI (){
    var maxEVIValue = -100; // Start with a very small value
    
    // Iterate through the datatable to find the maximum EVI value
    for (var i = 0; i < 132; i++) {
      var num = datatable.get(i);
      var eviValue = ee.List(num).get(1); // Get the EVI value from the sublist
      
      
      if (eviValue > maxEVIValue) {
        maxEVIValue = eviValue; // Update the maximum if a larger value is found
        print(maxEVIValue);
      }
    }
    

}
findmaxEVI();

1 Answer 1

0

To get the highest value from a list, I think you can do it very easily with a reducer. A max reducer will return the maximum value in your list.

var maxEVIValue=datatable.reduce(ee.Reducer.max())

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.