#由于这个错误,我无法将图层导出到我的谷歌驱动器:导出的波段必须具有兼容的数据类型;发现不一致的类型:Float64 和 Float32。 (错误代码:3)。任何人都可以帮我解决这个问题吗?
var band = ['B11','B8', 'B4', 'B3', 'B2'];
var image = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").select(band).filterBounds(table)
.filterDate('2023-12-01','2023-12-31').filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE",20)).median()
.clip(table);
var visparams = {min:0.0, max:3000, bands:['B8','B4', 'B3']};
print(image, visparams,'image');
Map.addLayer(image,visparams, 'image');
var nd= function(image){
var ndwi= image.normalizedDifference(['B3','B8']).rename('NDWI');
return image.addBands(ndwi);
};
var nd1 = nd(image);
Map.addLayer(nd1.select('NDWI'),{palette: ['red', 'yellow', 'green', 'cyan', 'blue']},'nd2');
Export.image.toDrive({
image: nd1,
description: "NDWI_2023",
region: table,
maxPixels:380681498 ,
scale: 10,
})
您需要将图像中的条带转换为相同类型。由于您的 NDWI 波段可能是 Float64,因此您可以将图像中的所有波段投射到 Float64
var nd = function(image) {
var ndwi = image.normalizedDifference(['B3', 'B8']).rename('NDWI').toFloat(); // Ensure NDWI is in Float32
return image.addBands(ndwi);
};
var nd1 = nd(image).toFloat(); // Ensure the whole image is in Float32
Map.addLayer(nd1.select('NDWI'), {palette: ['red', 'yellow', 'green', 'cyan', 'blue']}, 'nd2');
Export.image.toDrive({
image: nd1,
description: "NDWI_2023",
region: table,
maxPixels: 380681498,
scale: 10 // define scale here
});