1

I am new to GEE and processing satellite imagery. I am trying to download Landsat 8 Raw Imagery with the max. cloud coverage. I get the following error when running the task:

Error: Exported bands must have compatible data types; found inconsistent types: UInt16 and Int16. (Error code: 3)

I found people having similar issues but their code looks very different. I thought B2/B3/B4 all have the same UINT16 type, so I'm not sure what to change here.

Anyone know where the Int16 comes from? And how to change the format of the problematic band?

Code sample:


// Load Landsat 8
var image = ee.ImageCollection("LANDSAT/LC08/C02/T1")
.filterDate('2022-01-05','2022-01-15')
.filterBounds(roi)
.sort('CLOUD_COVER')
.first();

var visPaaramsTrue = {bands: ['B4', 'B3', 'B2'], min: 0, max:30000, gamma: 1.2};
Map.addLayer(image.clip(roi), visPaaramsTrue, 'Landsat 2022')
Map.centerObject(roi, 10);

// Export to Drive
Export.image.toDrive({
  image: image,
  description: 'Landsat 2022',
  scale:30,
  region: roi,
  maxPixels: 1e13
});

Edit (working code):


// Load Landsat 8
var image = ee.ImageCollection("LANDSAT/LC08/C02/T1")
.filterDate('2022-01-05','2022-01-15')
.filterBounds(roi)
.sort('CLOUD_COVER')
.first();

var visPaaramsTrue = {bands: ['B4', 'B3', 'B2'], min: 0, max:30000, gamma: 1.2};
Map.addLayer(image.clip(roi), visPaaramsTrue, 'Landsat 2022')
Map.centerObject(roi, 10);

// Export to Drive
Export.image.toDrive({
  image: image.select ('B4', 'B3', 'B2'),
  description: 'Landsat 2022',
  scale:30,
  region: roi,
  maxPixels: 1e13
});

1 Answer 1

2

If you print the image, print(image), and inspect the results, you can see that some bands are signed and some unsigned. The drive export is very strict when it comes to the data type - everything need to be the same.

Perhaps you're only interested in a subset of the bands, like the B.* ones, which all have the same data type. Then you just select them when exporting: image.select('B.*').

If you need bands that have different data type, you can cast all bands to the same data type when exporting. Take care that they don't overflow. I'm not sure you can get away with image.int16(). image.int32() would work, but is a bit wasteful.

If you do need all bands but don't want to use bigger data types than needed, you can make several exports.

0

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.