Export Landsat Bands – How to Select Landsat Bands to Download from Google Earth Engine

errorexportgoogle-earth-enginelandsat

I am trying to download a specific Landsat scene (since the USGS EROS site is down from the government shutdown) using the imageToCOGeoTiff task to save to my Google Drive. I am using the USGS Landsat 8 Collection 1 Tier 1 TOA Reflectance data.
I get the error message:

Error: Exported bands must have compatible data types; found inconsistent types: Float32 and UInt16.

I understand that all bands are "float" except for the BQA band which is "int16". I only need bands 1 – 11, not the BQA. Is there any way to select the bands I want (or to remove the BQA band)?

This is what I have so far (I am very new to GEE and most of this code was derived from elsewhere):

var lsat = ee.Image(landsat.filterDate('2016-06-27','2016-06-29').filterBounds(point).first());

// Print the image to the console
print(lsat);

// Define vis parameter
var trueColor = {
  bands: ['B4','B3','B2'],
  min: 6000,
  max: 13000,
};

// Add the image to the map
Map.addLayer(lsat,trueColor,'True Color Image');

// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
  image: lsat,
  description: 'imageToCOGeoTiffExample',
  scale: 30,
  fileFormat: 'GeoTIFF',
  maxPixels: 11629187501,
  formatOptions: {
    cloudOptimized: true
  }
});

Best Answer

You could use the following to select the first 11 bands:

// select the first 11 bands
var lsat = lsat.select(ee.List.sequence(0,10)); // or e.g. select([0,3,7]) for some other bands 

You could also cast the bands to the same data type:

// cast image to same data type
var toFloat = lsat.toFloat();