//filtrar imagens
var sr_landsat = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA")
.filterBounds(geometry)
.filterDate('2021-01-01', '2022-03-31');
print(sr_landsat);
// Get the number of images.
var count = sr_landsat.size();
print('Count: ', count);
// Get the date range of images in the collection.
var range = sr_landsat.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date range: ', ee.Date(range.get('min')), ee.Date(range.get('max')))
// Sort by a cloud cover property, get the least cloudy image.
var image = ee.Image(sr_landsat.sort('CLOUD_COVER').first());
print('Least cloudy image: ', image);
// Limit the collection to the 10 most recent images.
var recent = sr_landsat.sort('system:time_start', false).limit(10);
print('Recent images: ', recent);
// Imagem cortada para a área, em um único arquivo (camada)
var rgb = image.select('B4', 'B3', 'B2');
var pan = image.select('B8');
// Convert to HSV, swap in the pan band, and convert back to RGB.
var huesat = rgb.rgbToHsv().select('hue', 'saturation');
var sr_landsat = ee.Image.cat(huesat, pan).hsvToRgb();
// There are many fine places to look; here is one. Comment
// this out if you want to twiddle knobs while panning around.
Map.centerObject(geometry, 10);
// Display before and after layers using the same vis parameters.
Map.addLayer(rgb, {max: 0.3}, 'Original');
Map.addLayer(sr_landsat, {max: 0.3}, 'Pansharpened');
// Export the image, specifying scale and region.
// alterar apenas o description
Export.image.toDrive({
image: sr_landsat,
description: image.get('LANDSAT_PRODUCT_ID').getInfo(),
scale: 10,
region: geometry
});
//clicar em Run, depois em aba Tasks -> Run