I am trying to make mean Sentinel-2 images of an area for each day from May 1st to June 30th over several years. I've never used google earth engine/javascript before, so it's been a bit challenging.

Here's what I've come up with so far, copy pasted together from various sources:

///cloud mask (included just in case my error comes from here)
function maskS2clouds(image) {
  var qa = image.select('QA60');
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
  return image.updateMask(mask).divide(10000)
      .copyProperties(image, image.propertyNames());

///making an image collection over the relevant area/time period
var tiles = ['32VKM','32VLM']
var hardanger = ee.ImageCollection('COPERNICUS/S2').filter(ee.Filter.dayOfYear(120,180)) 
    .filter(ee.Filter.inList('MGRS_TILE', tiles))
    .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10))
//getting the mean image per day:

var days = ee.List.sequence(120, 180);
var byDay = ee.ImageCollection.fromImages(
    days.map(function(y) {
      return hardanger
        .filter(ee.Filter.calendarRange(y, y, 'DAY_OF_YEAR'))
        .set('DAY_OF_YEAR', y);
print(byDay, "byDay");

It seems to work fine and I do get 61 images, which seems about right (some are empty/no bands which I assume is because the satellite does not pass on those days).

However, all the images look exactly the same?

1 Answer 1


It looks like you did it correctly.

Just sticking the collection on the map and inspecting a point, you can see that the values are different over time. What makes you think they all look the same?

enter image description here

  • thanks for your quick answer! I just realized that my problem was that I added the same image as a layer 15 times by doing it this way: //Map.addLayer(hardanger, rgbVis, '10'); rather than adding 15 different images. Commented Aug 4, 2021 at 11:51

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.