I am trying to find and mosaic the least cloudy Landsat 8 OLI scene per tile, filtered by my region and for the year 2015.
I tried using this post to do so. However, unlike Sentinel 2A, there is no unique tile identifier in L8 tiles. I will have to extract unique combinations of the PATH and ROW properties, which I do not know how to do. My code is below, where i get multiple errors- 1) I am unable to extract distinct combination of path and rows stored in tiles using .distinct() as only one property can be used 2) Even when using only PATH as a property in .distinct(), my error says that I am trying to compile a non-image element in var leastCloudy
But the main question I have is how do i filter the image collection to give me the least cloudy scene per tile in the L8 OLI image collection.
//2. Loading L8 image collection (TOA reflectance)
var l8_collection= ee.ImageCollection('LANDSAT/LC08/C01/T1_SR');
//3. Filter by time window (Jan 2015- Dec 2015) for region (private asset)
var x1= l8_collection.filterBounds(asset)
.filterDate('2015-01-01', '2015-12-31')
.sort('CLOUD_COVER');
print ('L8 2015 image collection:',x1);
print('# images', x1.size()); //446 images
var max_x1=x1.max();
var visParams = {bands: ['B4', 'B3', 'B2']}; // Temporally composite the images with a maximum value function.
Map.addLayer(max_x1, visParams, 'max value composite');
// Load Footprint of Landsat WRS-2 grids
var wrs2_descending = ee.FeatureCollection('users/tnccarbonscience/wrs2_descending')
var wrs2_filtered = wrs2_descending.filterBounds(asset);
print('L8 tile info',wrs2_filtered);
Map.addLayer(wrs2_filtered);
var Tiles = ee.List(wrs2_filtered.distinct(["PATH"]).aggregate_array('PATH'));
print("List of unique L8 paths", Tiles);
//Extract least cloudy L8 scene in each tile
var leastCloudyPerPathRow = ee.ImageCollection.fromImages(Tiles.map(function(tile){
var filtCol = x1.filter(ee.Filter.eq("PATH", tile));
var leastCloudy = ee.Image(filtCol.sort('CLOUDY_PIXEL_PERCENTAGE').first());
return leastCloudy;
}));
print ("Size of least cloudy image collection",leastCloudyPerPathRow.size());
print ("least cloudy image collection",leastCloudyPerPathRow);