0

I try to get the timestamp of the least cloudy image for my region of interest (roi). I want to obtain the date of this image in the time range 2012-10-01 - 2012-12-31. I know that the image exists since I can get a real colour map but I get the following error when using the code below:

"Date: Parameter 'value' is required."

var l7coll_2012 = ee.ImageCollection('LANDSAT/LE07/C01/T1_SR')
.filter(ee.Filter.lt('CLOUD_COVER',25))
.select(['B7','B6' ,'B5' , 'B4' , 'B3', 'B2', 'B1'])
.filterDate('2012-10-01', '2012-12-30')
.map(function(image){
  var filled1a = image.focal_mean(2, 'square', 'pixels', 1)
  return filled1a.blend(image);
})

var l7_roi_2012 = l7coll_2012.median().clip(roi)
Map.addLayer(l7_roi_2012, {bands: ['B3', 'B2', 'B1'],min:0, max: 3000}, 'Real colour');

print('Timestamp: ', ee.Date(l7coll_2012.get('system:time_start')))

If I use the following adjustment, it works for landsat 8 images but I still get the same error for landsat 7 image.

var date_2012 = l7coll_2012.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date 2012:' , ee.Date(date_2012.get('max')))

Working landsat 8 code:

var l8coll_2013 = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filter(ee.Filter.lt('CLOUD_COVER',25))
.filterBounds(roi)
.filterDate('2013-10-01', '2013-12-30')
.map(function(image){
  return image.rename(['B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11']);
})

var date_2013 = l8coll_2013.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date 2013:' , ee.Date(date_2013.get('max')))

Does anyone know how I can get the timestamp for a landsat 7 image?

1 Answer 1

0

After hours of trying and failing I decided to post this question and of course, you'll see that you fix it yourself within ten minutes...

The function to fill the missing pixels changed the characteristics of the image in such a way that only the band reflectance was left, so there was no date to print. If I remove this part of the code:

.map(function(image){
  var filled1a = image.focal_mean(2, 'square', 'pixels', 1)
  return filled1a.blend(image);

I do get the right timestamp using this code:

var date_2012 = l7coll_2012.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date 2012:' , ee.Date(date_2012.get('max')))

Thanks for your effort If you were already working on it. Greetings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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