I am trying to download Landsat 4 SR data using the below code. But it is showing the error
'Line 33: Collection.toList: The value of 'count' must be positive. Got: 0.'
Code:
var geometry = /* color: #d63000 */ee.Geometry.Polygon(
[[[151.6174249560105, -30.397813382147582],
[151.62892626826635, -30.417429838395567],
[151.65579127375952, -30.411434283245875],
[151.62885523162248, -30.39332285985209],
[151.62233209929826, -30.39561792418842]]]);
/**
* Function to mask clouds based on the pixel_qa band of Landsat SR data.
* @param {ee.Image} image Input Landsat SR image
* @return {ee.Image} Cloudmasked Landsat image
*/
var cloudMaskL457 = function(image) {
var qa = image.select('pixel_qa');
// If the cloud bit (5) is set and the cloud confidence (7) is high
// or the cloud shadow bit is set (3), then it's a bad pixel.
var cloud = qa.bitwiseAnd(1 << 5)
.and(qa.bitwiseAnd(1 << 7))
.or(qa.bitwiseAnd(1 << 3));
// Reme edge pixels that don't occur in all bands
var mask2 = image.mask().reduce(ee.Reducer.min());
return image.updateMask(cloud.not()).updateMask(mask2);
};
var dataset = ee.ImageCollection('LANDSAT/LT04/C01/T2_SR')
.filterDate('1988-01-01', '1992-12-31')
.filterBounds(geometry)
.map(cloudMaskL457);
var l4_composite_list = dataset.toList(dataset.size());
// Number of image in the list
var n = l4_composite_list.size().getInfo();
// Find all the images less than 5% cloud cover and export to Google Drive
for (var i = 0; i < n; i++){ //put an actual angled bracket here
var img = ee.Image(l4_composite_list.get(i));
var rgb = img.select('B2','B3', 'B4').float();
var date = img.date().format('yyyyMMdd').getInfo();
Map.addLayer(img, {bands: ['B4', 'B3', 'B2'], min:0, max: 3000}, 'Image_'+date);
// Export to Google Drive
Export.image.toDrive({
image: rgb,
description: 'L4_RGB'+ date,
scale: 30,
region: geometry,
})
}
How can I fix this?