I would like to export the NDVI with the date in the filename in one image. Now I can only export them respectively. And when I export the NDVI image, it shows the error "Error: Exported bands must have compatible data types; found inconsistent types: Int16 and Byte." This is the code:

//study area
var roi = /* color: #d63000 */ee.Geometry.Polygon(
        [[[108.04782666015626, 22.81419793085548],
          [108.70837963867189, 22.829387337342464],
          [108.69876660156251, 23.183323796154976],
          [108.05194653320314, 23.16438649072554]]]);

var geometry = /* color: #d63000 */ee.Geometry.Point([108.50995736836717, 23.048234117697987]);

//cloud mask
function maskL8sr(image) {
// Bits 3 and 5 are cloud shadow and cloud, respectively.
 var cloudShadowBitMask = (1 << 3);
 var cloudsBitMask = (1 << 5);
// Get the pixel QA band.
 var qa = image.select('pixel_qa');
// Both flags should be set to zero, indicating clear conditions.
 var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
return image.updateMask(mask);

var L8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")

var rgb_vis = {min: 0, max: 3000, bands:['B4', 'B3', 'B2']};
var falsecolor = {min: 0, max: 3000, bands:['B5', 'B4', 'B3']};
var filtered = L8.filterDate('2018-01-01', '2018-12-31')
//Map.addLayer(filtered, falsecolor, 'falsecolor');

//add ndwi
var addNDVI = function(image) {
  return image.addBands(image.normalizedDifference(['B5','B4']).rename('NDVI'));
var imagen2=L8.map(addNDVI);

var NDVI = imagen2

var ndvifilter = NDVI.filterDate('2018-01-01', '2018-12-31')

// Visualize NDVI
var ndviPalette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
  '74A901', '66A000', '529400', '3E8601', '207401', '056201',
  '004C00', '023B01', '012E01', '011D01', '011301'];
            {min:0, max: 1, palette: ndviPalette}, 'ndvi');

//List NDVI
var list=ndvifilter.toList(200);
    for (var i=0;i<200;i++){
         var ndvibatch=ee.Image(list.get(i));
         var date = ndvibatch.date().format('yyyy-MM-dd').getInfo()
         var name= 'NDVI_'+date
    // Export NDVI        
               image: ndvibatch,
               description: name,
               fileNamePrefix: name,
               scale: 30,
               maxPixels: 1e13

The Code link: https://code.earthengine.google.com/b6f6cf802ac8a6667ec20ca6dedffce7

1 Answer 1


You are exporting all SR bands plus your NDVI band. That's 9 bands of shorts, 3 bands of bytes and 1 band of float numbers. But the geotiff file format doesn't allow mixing different types in the same file. So you either need to select just the bands you want (perhaps just the NDVI band?):

ndvibatch = ndvibatch.select('NDVI')

or convert all the bands to the same format:

ndvibatch = ndvibatch.float()

or export the different bands separately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.