0

In the below code, I want to join two image collections based on system:time_start property but it does not work and returns 0 element. Collections acquisition dates are same but they are different in acquisition hour so that causes error. Does anyone know any solution on this?

code link: https://code.earthengine.google.com/4acd9c3482cd89bc5f2f48e1a69cc490

var temp = mod11.select('LST_Day_1km')
.filterDate('2010', '2011')
.map(function(img){
  var time = ee.Date(img.get('system:time_start'))
  return img
  .copyProperties(img,img.propertyNames())
  .set('time',time)
  })

var wat = ocean.select('chlor_a')
.filterDate('2010','2011')
.map(function(img){
  var time = ee.Date(img.get('system:time_start'))
  return img
  .copyProperties(img,img.propertyNames())
  .set('time',time)
  })



var innerJoin = ee.Join.inner();

var filter = ee.Filter.equals({
  leftField: 'system:time_start',
  rightField: 'system:time_start'
});

var innerJoinData = innerJoin.apply(temp, wat, filter);

var datasets =  ee.ImageCollection(innerJoinData.map(function(img){
  return ee.Image.cat(img.get('primary'), img.get('secondary'))
  .copyProperties(img,img.propertyNames())
}));


print(datasets)

1 Answer 1

1

You can use ee.Filter.maxDifference(). There's an example in the user guide:

// Define a max difference filter to compare timestamps.
var maxDiffFilter = ee.Filter.maxDifference({
  difference: 2 * 24 * 60 * 60 * 1000,
  leftField: 'system:time_start',
  rightField: 'system:time_start'
});
0

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.