I am beginner in GEE and trying to apply cloud mask in my study area. I found one code and trying to apply in my area: link: https://code.earthengine.google.com/31b5b21913eefdc05563dfec72c4ee08 I am trying export image to gdrive. However, I faced following error:" Exported bands must have compatible data types; found inconsistent types: Int16 and Byte" while trying to export image. Kindly check code and fix this error

[![var point = /* color: #98ff00 */ee.Geometry.Point(\[74.146537,36.255872\]);

//load images for composite
var sr14= ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
//.select(\['B4','B3','B2'\]); // if you select those bands you loose BQA band

// Temporally composite the images with a maximum value function.
var composite = sr14.max();
Map.setCenter( 74.146537,36.255872);
var vis = {bands:\['B3','B6'\],min:0, max:5000}

Map.addLayer(composite, vis, 'max value composite');

var mask = require('users/fitoprincipe/geetools:cloud_masks')


var mask_function = mask.landsatSR() // mask function

var col_free = sr14.map(mask_function) // apply function to collection
var composite_free = col_free.max() // create composite using max

Map.addLayer(composite_free, vis, 'composite collection without clouds');
// Export a cloud-optimized GeoTIFF.
  image: composite_free,
  description: 'imageToCOGeoTiffExample',
  scale: 30,
  region: point,
  fileFormat: 'GeoTIFF',
  folder : 'My Drive/Landsat',
  maxPixels: 1e13

1 Answer 1

// Print out the image
 // The composite has 11 bands, first 9 bands (B1-B9) has datatype of signed int16. 
 // However, rest of the bands have different data types (unsigned int8; unsigned int18)
 print("Check first image:",composite_free);

 // Solution 
 // If you only want first nine bands, then just select these bands (which means exclude others)
 // you can do this using select() function
 // composite_free.select(['B1','B2','B3','B4','B5','B6','B7','B8','B9'])

 var selectedBandsComp = composite_free.select(['B1','B2','B3','B4','B5','B6','B7','B8','B9'])

 // Now use selectedBandsComp to export
 // Export a cloud-optimized GeoTIFF.
 Export.image.toDrive({ image: selectedBandsComp,
 description: 'imageToCOGeoTiffExample',
 scale: 30,
  region: point,
  fileFormat: 'GeoTIFF',
  folder : 'My Drive/Landsat',
  maxPixels: 1e13


  • it is not exporting correct results. You can check exported image by using this link :drive.google.com/file/d/1xguT-HS8KZRbqAR31r6mGywO9y_v5wJN/… Jun 8, 2021 at 10:16
  • Hi Usman, please provide your complete working script so that we can evaluate. Regarding your original question, you asked about band data types, so one way of exporting is to select the bands of interest. Now, regarding cloud masking, I tried to make one script and included comments where you can find related discussion here in stackexchange in the script. Hope this helps Link
    – mandal
    Jun 8, 2021 at 13:35
  • sorry for misunderstanding. I tried to use your previous link. Bands are exported in gdrive but images show zero values when I opened these bands in Arcmap for further processing. My overall aim to obtain cloud mask landsat images or to remove clouds from landsat images in my study area and exported in my gdrive. Kindly check my script code.earthengine.google.com/9337df69f9fe867b4334ed956fa6a191 Jun 8, 2021 at 17:43
  • Hi Usman, when you want to export, you need to define your region of interest (e.g. polygons). More information about how to export you can find in this doc developers.google.com/earth-engine/guides/exporting. So, when I made an polygon and used it to export, it works fine (Checked after exporting). I am not sure about the cloud mask function you have used, but I am sure you know what you are doing. Best of luck for your research. Script: code.earthengine.google.com/848e8b7de5b989684170a44d097e388e
    – mandal
    Jun 11, 2021 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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