1

I am using Earth Engine to retrieve Sentinel 2 data. I thought that for a given date and place, I would find only one Sentinel image (revisit time is multiple days). I notice however that for some dates, Earth Engine records two images that seem very similar (at least visually: same values, same bounding box).

Why are there two images? If I were to take only one, which one should I take?

Code: https://code.earthengine.google.com/0dd7199e04a6ca5b22684fb3a09a8c40

var senti_same = ["20150803T170236_20160825T061733_T15SXD",
                  "20150803T170231_20160520T064257_T15SXD"]
var senti2 = ee.ImageCollection("COPERNICUS/S2").
    filter(ee.Filter.inList("system:index", senti_same))

print(senti2)

var senti2_list = senti2.toList(2);

print(ee.Date(ee.Image(senti2_list.get(0)).get("system:time_start")))
print(ee.Date(ee.Image(senti2_list.get(1)).get("system:time_start")))


// map
Map.setCenter(-91.1625, 39.2862, 9)
Map.addLayer(ee.Image(senti2_list.get(0)), 
             {bands: ["B4", "B3", "B2"], max: 255*10}, "image 2")
Map.addLayer(ee.Image(senti2_list.get(1)), 
             {bands: ["B4", "B3", "B2"], max: 255*10}, "image 2")
1
  • 2
    Neither of the two answers provided so far answer the OP: Why are there two images on the same date and place?
    – Stu Smith
    Mar 27, 2021 at 16:04

2 Answers 2

1

As per the user handbook, file naming conventions include date and timestamp of data collection and processing. For the two images you include, the timestamp for image collection was at 17:02:36 and 17:02:31 on 03 Aug 2015. So, the values are likely nearly identical because the two images were captured 5 seconds apart from one another. As far as which one to take, it's probably worth looking to see if there are any differences in metadata that would lead you to choose one over the other.

Edit: this additional snippet of code provides further support that there aren't any major differences between the two images:

var senti_img1 = ee.Image("COPERNICUS/S2/20150803T170236_20160825T061733_T15SXD");
var senti_img2 = ee.Image("COPERNICUS/S2/20150803T170231_20160520T064257_T15SXD");

var diff = senti_img1.subtract(senti_img2);
Map.addLayer(diff,{},"Difference");

Second edit: Looking at each band of var diff it doesn't look like any differences exist in data layers or in QA layers.

print(diff);
Map.addLayer(diff.select("B1"),{},"Difference band 1");
Map.addLayer(diff.select("B2"),{},"Difference band 2");
Map.addLayer(diff.select("B3"),{},"Difference band 3");
Map.addLayer(diff.select("B4"),{},"Difference band 4");
Map.addLayer(diff.select("B5"),{},"Difference band 5");
Map.addLayer(diff.select("B6"),{},"Difference band 6");
Map.addLayer(diff.select("B7"),{},"Difference band 7");
Map.addLayer(diff.select("B8"),{},"Difference band 8");
Map.addLayer(diff.select("B8A"),{},"Difference band 8A");
Map.addLayer(diff.select("B9"),{},"Difference band 9");
Map.addLayer(diff.select("B10"),{},"Difference band 10");
Map.addLayer(diff.select("B11"),{},"Difference band 11");
Map.addLayer(diff.select("B12"),{},"Difference band 12");
Map.addLayer(diff.select("QA10"),{},"Difference band QA10");
Map.addLayer(diff.select("QA20"),{},"Difference band QA20");
Map.addLayer(diff.select("QA60"),{},"Difference band QA60");
1
  • thanks! I guess I was confused about the fact that there are sometimes two images taken at nearly the same time! Did you see that mentioned in the handbook, I think I missed it?
    – Matifou
    Feb 17, 2019 at 19:20
1

The following function simplify data into daily mosaics

function dailyMosaics(imgs){
    //Simplify date to exclude time of day
    imgs = imgs.map(function(img){
    var d = ee.Date(img.get('system:time_start'));
    var day = d.get('day');
    var m = d.get('month');
    var y = d.get('year');
    var simpleDate = ee.Date.fromYMD(y,m,day);
    return img.set('simpleTime',simpleDate.millis());
    // return ee.Image(img.copyProperties(img, 
    img.propertyNames())).set('simpleTime',simpleDate.millis());
    });
  
    //Find the unique days
    var days = ee.Dictionary(imgs.aggregate_histogram('simpleTime')).keys();
    imgs = days.map(function(d){
    d = ee.Number.parse(d);
    d = ee.Date(d);
    var t = imgs.filterDate(d,d.advance(1,'day'));
    var f = ee.Image(t.first());
    t = t.mosaic();
    t = t.set('system:time_start',d.millis());
    t = t.copyProperties(f, f.propertyNames());
    return t;
    });
    imgs = ee.ImageCollection.fromImages(imgs);
    
    //Remove edge artifacts
    imgs = imgs.map(function(img){return img.updateMask(img.mask().reduce(ee.Reducer.min()))});
    
    return imgs;
}

An example application would be:

var S2_col_dailyMosaic = dailyMosaics(my_S2_col)

Your Answer

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

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