I am looking for a way to filter images for certain dates per feature in the feature collection. I want a function that would take each individual feature from the feature collection and then check from the image collection if there is an S1 image available for that region for a particular date. The dates are also listed in a column in the feature collection for each feature. So for feature1 is there an image for 2016-04-17 in the S1 collection, if yes select that feature. The feature collection table contains a column called 'SrcImgDate'. So I just want to filter out a feature collection with features that have an image for the srcimgdate next to them.

Expected output: FeatureCollection with all features that intersect with an image at the given srcimgdate and location

This is the imageCollection with a general date range

var Sentinel1 = S1.filter(ee.Filter.eq('transmitterReceiverPolarisation', pol))
                  .filterMetadata('instrumentMode', 'equals', 'IW')
                  .filterDate('2016-04-01','2016-08-30' )
                  .filterMetadata('resolution_meters', 'equals' , 10);

Here is the link to the FeatureCollection. You can limit it to 1000, as it has 11000 feature and would give an error to use such a large dataset. https://code.earthengine.google.com/?asset=users/rawailnaeem/CA

  • I am really having a hard time trying to understand what you want to do. If you want to filter the FeatureCollection in each Feature when you loop over it, you won't get a single FeatureCollection as output. Aug 26, 2018 at 2:43
  • Multiple feature collections would work too. Each feature has an attribute called 'SrcImgDate' and I need to see if this date matches a 'system:time start' date from the image. If yes, I want that feature to be filtered. I hope this makes some sense now. Aug 27, 2018 at 4:45
  • What's the value of pol in S1.filter(ee.Filter.eq('transmitterReceiverPolarisation', pol))? Aug 27, 2018 at 11:09
  • I have done it, but there is not matching, the resulting FeatureCollection is empty, have a look and see if it is what you want, and let me know. code.earthengine.google.com/45b0615bfcc67063e77b55a57fc5e0bf Aug 27, 2018 at 12:31
  • 1
    I found the error, it was due to milliseconds, image's dates where in the same day but not exactly in the same millisecond. Aug 28, 2018 at 21:25

1 Answer 1


In this approach I am not selecting VH and VV bands because some images in the collection don't have them (or one of them). Also, I am not filtering by transmitterReceiverPolarisation because the question does not provide one.

var table = ee.FeatureCollection("users/rawailnaeem/CA");
var S1 = ee.ImageCollection("COPERNICUS/S1_GRD");

var t = table.limit(1000);

var Sentinel1 = S1.filterMetadata('instrumentMode', 'equals', 'IW')
                  .filterDate('2016-04-01','2016-08-30' )
                  .filterMetadata('resolution_meters', 'equals' , 10)

var S1dates = Sentinel1.toList(Sentinel1.size()).map(function(img){
  var idate = ee.Image(img).date();
  return ee.Date.fromYMD(

// print images dates
print(S1dates.map(function(millis) {
  return ee.Date(millis).format();

var newfc = ee.List(t.iterate(function(feat, ini){
  // cast
  var ini = ee.List(ini);
  var feat = ee.Feature(feat);

  // get src date
  var srcd = ee.String(feat.get('SrcImgDate'));
  var year = ee.Number.parse(srcd.slice(0, 4));
  var month = ee.Number.parse(srcd.slice(4, 6));
  var day = ee.Number.parse(srcd.slice(6, 8));

  var date = ee.Date.fromYMD(year, month, day).millis();

  var condition = S1dates.contains(date);

  return ee.Algorithms.If(condition, ini.add(feat), ini);
}, ee.List([])));

var newfc = ee.FeatureCollection(newfc);


Your Answer

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

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