0

I posted this in the developers forum as it sounds to me like an internal error rather than an error in the code but I've not received a response so I'm trying my luck here.

I'm trying to create a DOY band on an image collection. I found a similar question on stackexchange which includes a function for doing this (Add a date (day of year) band to each image in a collection using Google Earth Engine). This code works fine.

When I try to run the function on my ImageCollection I get an error message:

ImageCollection (Error) Error in map(ID=20170601T102019_20170601T102022_T33UUU): Image.date: Image does not have a valid system:time_start property!

This sounds to me like there is an error in the metadata in one of the images in my collection. Can anyone help solve this?

NB. 'aoi' is a multipolygon shapefile.

Here is a link to my code in gee:

https://code.earthengine.google.com/f4fc313d1fa22f5ff6e0a9eb802f8970

Vince
  • 20,017
  • 15
  • 45
  • 64
Adam G
  • 331
  • 5
  • 15
  • Please remember to include your code in the body of GIS SE questions. Links fail over time and cannot be indexed to locate the question. – Vince May 03 '19 at 12:17

1 Answers1

1

When you divide or multiply an image, it loses its original properties. Replace your function by explicite copying the original properties:

function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return ee.Image(image.updateMask(mask)
  .divide(10000).copyProperties(qa)).set('system:time_start', qa.get('system:time_start'));
}
Vince
  • 20,017
  • 15
  • 45
  • 64
Kuik
  • 10,043
  • 1
  • 12
  • 19