Corrija o seguinte erro no script do google earth engine: o Erro: ImageCollection…
- User
Corrija o seguinte erro no script do google earth engine: o Erro:
ImageCollection (Error) Error in map(ID=LC08_221067_20240524): Image.rename: The number of names (3) must match the number of bands (1). composite sharp1: Layer error: reduce.median: Error in map(ID=LC08_221067_20240625): Image.rename: The number of names (3) must match the number of bands (1).
O script:
// Function to mask clouds using the quality band of Landsat 8. var maskL8 = function (image) { // Bit 0 - Fill // Bit 1 - Dilated Cloud // Bit 3 - Cloud // Bit 4 - Cloud Shadow var qaMask = image.select('QA_PIXEL') .bitwiseAnd(parseInt('11111', 2)).eq(0); var saturationMask = image.select('QA_RADSAT').eq(0);
// Apply the scaling factors to the appropriate bands. var opticalBands = image.select('B.') //.multiply(0.0000275).add(-0.2); //var thermalBand = image.select('ST_B.*').multiply(0.00341802).add(149.0);
// Replace the original bands with the scaled ones and apply the masks. return image.addBands(opticalBands, null, true) //.addBands(thermalBand, null, true) .updateMask(qaMask) .updateMask(saturationMask); }
var kernel = ee.Kernel.square({ radius: 90, units: 'meters' });
var pansharpen1 = function(scene) { // Compute the per-pixel means of the unsharpened bands. var bgr = scene.select(['B7', 'B5', 'B4']); var pan = scene.select(['B8']); // Certificando de que a seleção é feita corretamente var bgr_mean = bgr.reduce('mean').rename(['mean_B7', 'mean_B5', 'mean_B4']);
// Compute the aggregate mean of the unsharpened bands and the pan band. var mean_values = pan.addBands(bgr_mean).reduceNeighborhood({ reducer: ee.Reducer.mean(), kernel: kernel, });
var gain = mean_values.select('mean_B7').divide(mean_values.select('B8_mean'));
return bgr.divide(bgr_mean).multiply(pan).multiply(gain); };
// Map the function over one year of Landsat 8 TOA data and take the median. var L8 = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA') .filterDate('2024-01-01', '2024-12-31') .filterBounds(geometry) .map(maskL8) .map(pansharpen1);
var L9 = ee.ImageCollection('LANDSAT/LC09/C02/T1_TOA') .filterDate('2024-01-01', '2024-12-31') // Confirme a data de filtro .filterBounds(geometry) .map(maskL8) .map(pansharpen1);
var composite = L8.merge(L9);
// Aplicar o pansharpen var sharpComposite = composite.map(pansharpen1);
print(composite, 'composite');
Map.addLayer(sharpComposite.median(), {bands: ['B7', 'B5', 'B4'], max: 0.3}, 'sharp1');
- Assistant
O erro que você está enfrentando está relacionado à renomeação das bandas. O erro ocorre porque a função de redução que você está usando (
reduceNeighborhoodereduce) retorna apenas uma banda, mas você está tentando renomear essa banda com três nomes diferentes, o que causa a discrepância.