2

I tried to calculate Radar Vegetation Index with Google Earth Engine using the code given below. The Value of RVI should range between 0-1. but I'm getting following error

Code:

var RVI= function (image){
  var nom= image.select('VV')
  var din= image.select('VV').add(image.select('VH'))
  var dop= nom.divide(din) //equivalent to complement of the degree of polarization
  var m= 1-(dop)
  var value = (Math.sqrt(dop))*(((image.select('VH'))/(din)))//depolarization within the vegetation
  return value
  };

Error:

Collection.first: Error in map(ID=S1A_IW_GRDH_1SDV_20210503T125534_20210503T125559_037724_0473B3_F384): The mapped algorithm returned null but dropNulls was set to false. Set dropNulls to true to drop elements for which the algorithm returns null.

2
  • You need to post a complete example that demonstrates the error. Almost certainly, you have issues with the collection you're working on, but it's impossible to debug without seeing it. Jun 29, 2022 at 15:51
  • You have issues with the collection you're working on because your RVI formula is not correct. Please, see my answer.
    – xunilk
    Jun 30, 2022 at 0:55

1 Answer 1

6

You have issues with the collection you're working on because your RVI formula is not correct. By using the 'system:index' of following image in your error message:

S1A_IW_GRDH_1SDV_20210503T125534_20210503T125559_037724_0473B3_F384

I could find out that your roi is probably situated in some area in India. So, your original code lines in following code reproduces your error message.

var pt = ee.Geometry.Point (76.8576, 29.5632);

Map.centerObject(pt, 8);

// Load the Sentinel-1 ImageCollection, filter to Jun-Sep 2020 observations.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterMetadata('system:index', 'equals',
                     'S1A_IW_GRDH_1SDV_20210503T125534_20210503T125559_037724_0473B3_F384');

// Filter the Sentinel-1 collection by metadata properties.
var vvVhIw = sentinel1
  // Filter to get images with VV and VH dual polarization.
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
  // Filter to get images collected in interferometric wide swath mode.
  .filter(ee.Filter.eq('instrumentMode', 'IW'));

print(vvVhIw);

var RVI = vvVhIw.map(function (image){
  var nom = image.select('VV');
  var din = image.select('VV').add(image.select('VH'));
  var dop = nom.divide(din); //equivalent to complement of the degree of polarization
  var value = (Math.sqrt(dop))*(((nom)/(din)));//depolarization within the vegetation
  return value  });

print(RVI);

Map.addLayer(vvVhIw);

This can be observed in following image:

enter image description here

This kind of error can be solved by using suggestion in error message but, obtained collection is empty; observed in following image.

enter image description here

So, following code, where formula is corrected (by using a more comprehensive expression), produces a result without any issues.

var pt = ee.Geometry.Point (76.8576, 29.5632);

Map.centerObject(pt, 8);

// Load the Sentinel-1 ImageCollection, filter to Jun-Sep 2020 observations.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterMetadata('system:index', 'equals',
                     'S1A_IW_GRDH_1SDV_20210503T125534_20210503T125559_037724_0473B3_F384');

// Filter the Sentinel-1 collection by metadata properties.
var vvVhIw = sentinel1
  // Filter to get images with VV and VH dual polarization.
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
  // Filter to get images collected in interferometric wide swath mode.
  .filter(ee.Filter.eq('instrumentMode', 'IW'));

print(vvVhIw);

var RVI = vvVhIw.map(function (image){

  var rvi = image.expression('sqrt(vv/(vv + vh))*(vv/vh)',
    {'vv': image.select('VV'),
     'vh': image.select('VH')
    }

    );

    return rvi;
  });

var imageVisParam = {"opacity":1,
                     "bands":["VV"],
                     "min":0.01548,
                     "max":0.46221,
                     "gamma":1};

Map.addLayer(RVI.first(), imageVisParam, 'RVI');

It can be observed in following picture after running above code in GEE code editor. All RVI values ranged between 0-1.

enter image description here

2
  • Thank you so much, Sir, for your valuable time and guidence.
    – Reflex_180
    Jul 6, 2022 at 5:27
  • You're welcome. If you feel that it solves your question please, consider to mark it as accepted.
    – xunilk
    Jul 6, 2022 at 12:26

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