0

I'd like to create a Landsat 5,7 and 8 Image Collection for a given location, selecting for each year (and within the January to march month range) the scene with the least cloud cover.

So far I have homogenized the Landsat bands in a single collection and applied the Bounds and date ranges, but I cannot find a tool that would pick up a single image per year according to the lowest cloud coverage.

I have looked at the limit and sort tools, but I am still missing something. Below is my preliminary script.

//This code generates a landsat-family temporal series for a given location and
//provides a list of annual images with the least cloud cover. 

//homogenize Landsat family bands
var L8_bands = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7'];
var L7_bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7'];
var L5_bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7'];
var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'swir2'];

var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA').select(L8_bands, STD_NAMES);// Landsat 8
var l7 = ee.ImageCollection('LANDSAT/LE07/C01/T1_TOA').select(L7_bands, STD_NAMES); //Landsat 7
var l5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA').select(L5_bands, STD_NAMES); //Landsat 5

var lmerge = l8.merge(l7).merge(l5);
var lmerge_filter = lmerge.filter(ee.Filter.calendarRange(1985,2023,'year')).filter(ee.Filter.calendarRange(1,3,'month'))
  .filterBounds(geometry)
  .filterMetadata('CLOUD_COVER', 'Less_Than', 20);
print(lmerge_filter, 'collection');
0

1 Answer 1

0

You can define a function that selects the image with the lowest CLOUD_COVER for a given year, then map that function to a list of years that you want.

function leastCloudyImageByYear(year){
  // Select the least cloudy image by year
  return lmerge_filter.filter(ee.Filter.calendarRange(year,year,'year'))
  .sort("CLOUD_COVER").first()
}
var result = ee.ImageCollection(ee.List.sequence(1985,2023).map(leastCloudyImageByYear))
print(result) // 34 images

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

0

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.