1

I need help solving this GEE internal error. I am trying to reduce my script lines in GEE. So, I tried to use a single function to compute polarization indexes.

However, the console shows a warning saying: enter image description here

This is the script:

// Function to compute and add polarization indexes as bands
var addindexes = function(ima) {
  var NDPI = ima.select('VV').subtract(ima.select('VH'))
    .divide(ima.select('VV').add(ima.select('VH')));
  var NVHI = ima.select('VH').divide(ima.select('VV').add(ima.select('VH')));
  var NVVI = ima.select('VV').divide(ima.select('VV').add(ima.select('VH')));
  var VHrVV = ima.select('VH').divide(ima.select('VV'));
  var indexes = ee.List([NDPI,NVHI,NVVI,VHrVV]);
  return ima.addBands(indexes);
};

// Add index bands to image collection
var S1_indexes = allSeasons.map(addindexes);
print(S1_indexes);

1 Answer 1

1

Without a full script it is a little difficult to debug, but one problem I see is that you are providing an ee.List object to the addBands method, but it requires an ee.Image object. Try using ee.Image.cat instead of ee.List like this:

// Make toy data
var allSeasons = ee.ImageCollection(
  ee.Image.constant([25, 10]).rename('VV', 'VH'));
print(allSeasons);

// Function to compute and add polarization indexes as bands
var addindexes = function(ima) {
  var VV = ima.select('VV');
  var VH = ima.select('VH');
  var NDPI = VV.subtract(VH).divide(VV.add(VH));
  var NVHI = VH.divide(VV.add(VH));
  var NVVI = VV.divide(VV.add(VH));
  var VHrVV = VH.divide(VV);
  var indexes = ee.Image.cat(NDPI, NVHI, NVVI, VHrVV)
    .rename(['NDPI', 'NVHI', 'NVVI', 'VHrVV']);
  return ima.addBands(indexes);
};

// Add index bands to image collection
var S1_indexes = allSeasons.map(addindexes);
print(S1_indexes);

Note that I added two variables (VV and VH) so that ima.select() was not repeated.

1
  • Thank you very much! It worked and It's even better than I expected. Nov 14, 2019 at 13:13

Your Answer

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

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