1

I have two ImageCollections one from Sentinel-1 and the other from Sentinel-2. From S-2 i derive the NDVI. I want to add the NDVI band from the S2 Collection to the Sentinel-1 ImageCollection with the closest date. How can i do this?

GEE basic script

0

There are several ways to achive that. I would do that like this:

// map over the sentinel 1 collection
var appendNDViband = s1_grd_iw_vv_des.map(function(image){
  var dateS1 = ee.Number(image.get('system:time_start'));
  // map over the sentinel 2 collection 
  var appendAbsDifference = s2_cf_ndvi.select('NDVI').map(function(image){
    var dateS2 = ee.Number(image.get('system:time_start'));
    return image.set('absDifference', dateS2.subtract(dateS1).abs());
  });
  // calculate the image with the least absolute time difference
  var minDifference = appendAbsDifference.sort('absDifference').first();
  return image.addBands(minDifference)
              .set('propsS2', minDifference.toDictionary(minDifference.propertyNames().add('system:time_start')));
});

print('Sentinel-1 with NDVI band', appendNDViband);

Note that there will be differences in geometry and projection you will run into. Moreover, Sentinel 2 images are divided into MGRS tiles, you probably want to merge following this example.

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.