0

I have the following code:

var dataset = ee.ImageCollection('COPERNICUS/S3/OLCI')
                  .filterDate('2018-01-01', '2018-12-31');

// Select bands for visualization and apply band-specific scale factors.
var rgb = dataset.select(['Oa07_radiance', 'Oa05_radiance', 'Oa02_radiance'])
              .median()
              // Convert to radiance units.
              .multiply(ee.Image([0.00879161, 0.01009526, 0.01338726]));
              
              
var rgb1=rgb.clip(geometry);     


var visParams = {
  min: -6,
  max: 6,
  gamma: 1.5,
};

Map.setCenter(-0.64048, 35.71388, 16);
Map.addLayer(rgb1, visParams, 'rgb1');


////// Export to TIFF
Export.image.toDrive({

  image: rgb1,

  description: 'RGB',

  region: geometry,

  scale: 30,

  fileFormat: 'Geotiff',


});

When I run the code I get the following error:

Error: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'Oa07_radiance': Expected type: Integer. Actual type: Float. Image ID: S3B_20180516T095837_20180516T100137 This band might require an explicit cast. (Error code: 3)).

1 Answer 1

0

Some of the images in the collection have inconsistent data types, causing the median reducer to fail. As mentioned in the error message, you can fix this by explicitly casting each image to int32:

// Select bands for visualization and apply band-specific scale factors.
var rgb = dataset.select(['Oa07_radiance', 'Oa05_radiance', 'Oa02_radiance'])
              // Cast each image to the same type
              .map(function(img) {return img.int32()})
              .median()
              // Convert to radiance units.
              .multiply(ee.Image([0.00879161, 0.01009526, 0.01338726]));
1
  • Thank you Aaron Zuspan, now the code works perfectly;
    – user241222
    Mar 30 at 14:36

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.