TransWikia.com

Error while trying to integrate Leaf Area Index into ui.DateSlider

Geographic Information Systems Asked on December 13, 2020

I am trying to calculate Leaf Area Index in GEE by deriving LAI from NDVI (I found the formula in this thread from Research Gate forum https://www.researchgate.net/post/How_to_calculate_LAI_Leaf_Area_Index_from_Satellite_Images) and also I want to integrate it into a ui.DateSlider widget.

var sentinel_dataset = ee.ImageCollection("COPERNICUS/S2_SR")
 .filterDate(Start_period, End_period)

//Create NDVI
var collectionNDVI = sentinel_dataset.map(
    function(img) {
         return img.normalizedDifference(['B8','B4'])
               .rename('NDVI')
                  .copyProperties(img, ['system:time_start']);
                      });
                      
//Create LAI
var collectionLAI = sentinel_dataset.expression(
    '0.57 * exp(2.33 * NDVI)', {
      'NDVI': (collectionNDVI),
});

When I run this code, the console brings up this error: sentinel_dataset.expression is not a function

This is the link for my code https://code.earthengine.google.com/47d695de6faf894006516a447d095804
I tried multiple ways to write the expression but nothing seems to work. Is there another way to create LAI in this context?

One Answer

There are two problems in your approach. First, you are working wiht an ImageCollection and if you want to calculate LAI for a collection you need to apply a function using map(function). The second problem, you need to apply the funcion to a collection that already have an NDVI band, so apply it to collectionNDVI intead of sentinel_dataset.

//Create LAI function
var addLAI = function(image) {
  var lai = ee.Image(0).expression(
    '0.57 * exp(2.33 * NDVI)',
    {
      'NDVI':image.select('NDVI')
    });
  return image.addBands(lai.rename('lai'));
};


// Apply to NDVIcollection
var collectionLAI = collectionNDVI.map(addLAI);

// Have a look at the results

Map.addLayer(collectionLAI, {bands:'lai', min:0, max:1,palette:['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
               '74A901', '66A000', '529400', '3E8601', '207401', '056201',
               '004C00', '023B01', '012E01', '011D01', '011301']}, 'lai');

Correct answer by HMSP on December 13, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP