I have a feature collection (fc) with 29 features. Each feature has a "date" property, in the format "YYYY-MM-DD", the same format used to filter images by the filterDate() function.

var fc = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(-73.96, 40.781), {date: '2018-01-05'}),
  ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {date: '2018-07-04'})
  // 29 more features

For each feature there is an image. According to the geographical location and the date stored in the "date" property (e.g. for feature 1, I have a Sentinel-2 image that overlays its geometry ee.Geometry.Point(-73.96, 40.781) and that was acquired on a date close to the date stored in the "date" property date: '2018-01-05').

In this way I have created a collection of 29 images.

What am I looking for?

Now, based on this collection of Sentinel images, I would like to obtain a collection of Landsat images that were acquired on dates close to the acquisition dates of the Sentinel images and that overlap geographically.

I have tried to solve this problem in various ways and have not been able to get a handle on it.

1 Answer 1


Could map a function over your feature collection, fc, that filters the Landsat image collection according to the geometry and date-stamp of each feature, then returns the image with the closest date. Example:

var L = 30 ; // search window, +/- days 

var collect = ee.ImageCollection(
    var date = ee.Date(feature.get('date')) // target date 
    return ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
      // filter for location and date 
      .filterDate(date.advance(-L,'day'), date.advance(L,'day'))
      // set date difference between target date as image property 
        var diff = ee.Number(image.date().difference(date,'day')).abs()
        return image.set('diff', diff)})

      // filter by 'diff' and return closest image 
      .sort('diff', true)

  • Unfortunately, this is not the result I am looking for. I already did that in the first step. What I am looking for is another image collection that contains images acquired on dates close to the dates of the images in this collection that resulted from your script. Mar 3, 2021 at 12:07
  • 1
    Thanks @IagoMendesdeOliveira for clarifying. After reading your question again, I now understand that you are looking to filter a collection of Landsat images that are a similar date to a collection of Sentinel images (correct me if I'm wrong). Sounds like you should be able to modify my answer-or your own similar code- to map over your image collection (Sentinel), rather than fc. Changes would include replacing date = ee.Date(feature.get('date')) with date = image.date().
    – korndog
    Mar 3, 2021 at 16:56
  • Thanks @korndog. It worked perfectly! Mar 4, 2021 at 14:19

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.