0

I've wrot below code for time series processing via modis LST product, but it shows this error:

ImageCollection (Error) Error in map(ID=2018_06_02): Image.constant: Parameter 'value' is required.


Google Earth Engine Code: https://code.earthengine.google.com/69da688a94c65e05e3cac421d5bbd938

Map.centerObject(table);
Map.addLayer(table);


// test for tci
var modis = ee.ImageCollection('MODIS/006/MOD11A2')
.filterBounds(table)
.filterDate('2018-01-01','2019-01-01')
.select("LST_Day_1km")
.map(function(img){
  return img.multiply(0.02)
  .copyProperties(img,['system:time_start','system:time_end']);
});

var tci = modis.map(function(img){

  var min = img.reduceRegion(ee.Reducer.min(),table,1000).get('LST_Day_1km');
  var max = img.reduceRegion(ee.Reducer.max(),table,1000).get('LST_Day_1km');

  var index = img.expression(
    '(max-LST)/(max-min)'
    ,{
      'LST': img,
      'min': ee.Number(min),
      'max': ee.Number(max),
      }).rename('TCI')
      .copyProperties(img,['system:time_start','system:time_end']);
  return index;
});

print(tci)
1

That is because in that image there are only masked pixels. Thus, your reduceRegion for the min and max value do not return values. Your image expression therefore doesn't work and throws an error.

You can filter out images that do not contain any data inside your area of interest using:

function(img){
  var mulitplied = img.multiply(0.02)
  var unmasked = img.gt(-999).reduceRegion(ee.Reducer.count(),table,1000);
  return mulitplied.set('count', unmasked.get('LST_Day_1km'))
  .copyProperties(img,['system:time_start','system:time_end']);
});
// filter images not containing data in the study area 'table'
var filtered = modis.filter(ee.Filter.neq('count', 0));

Then you can continue working with the filtered image collection.

You can anlyse the image not working in any study area by:

var notWorking= modis.filter(ee.Filter.eq('count', 0));

Link script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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