I'm trying to perform a land cover classification task on Landsat 8 images using the RandomForest classifier in Google Earth Engine. I'd like to obtain an output where for each class I get a separate band with the corresponding posterior class probabilities. According to the Google Earth Engine documentation, this should be possible through the 'MULTIPROBABILITY' output mode.

However, when I try to use this output mode, the result is a single-band image. I have tried this will most other classifiers and always get a single band result. Below is the code snippet:

// Define bands and classifier
var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11', 'NDVI'];
var classifier = ee.Classifier.smileRandomForest({
  numberOfTrees: 100,
  minLeafPopulation: 3,
  bagFraction: 0.5,
  seed: 0,
  features: training,
  classProperty: 'classCode',
  inputProperties: bands

// Classify the image
var probabilities = composite.select(bands).classify(classifier);

// Print band names and types to the console
print('Band names: ', probabilities.bandNames());
print('Band types: ', probabilities.bandTypes());

Here, 'training' is a feature collection of training samples, and 'composite' is a cloud-free image composite of Landsat 8 images. When I inspect the band names and types of the 'probabilities' image, I get a single band.

I was wondering if I'm using the 'MULTIPROBABILITY' output mode correctly, or if there is another way to obtain the class probabilities for each class separately?

1 Answer 1


After much trial and error, I was able to find the solution. The output of a classifier with multiprobability output type is an array band.

So, after classifying the data, the output must be flattened:

// Classify the image
var probabilities = composite.select(bands).classify(classifier);

// Extract the probabilities for each cover type
var probabilities = classified.arrayFlatten([['bare', 'grass', 'trees', 'uluhe']]);

This results in an object with each band representing the probability of class membership for every class considered!

  • The docs expicitly say: "MULTIPROBABILITY: The output is an array of probabilities that each class is correct ordered by classes seen". Was that not clear enough or did you somehow miss it? Commented Aug 10, 2023 at 3:31
  • Thanks Noel for the input! I was not familiar with the array band type of object, so just expected for a stack or collection with n layers equivalent to the classes. Since I was not familiar with the array band, on inspection GEE would tell me it was a single layer, and when adding the result to the map, gee defaults to mapping the first array element without throwing a warning or error (that other array elements are present), so everything indicated to me that it was a single layer raster output. Commented Aug 23, 2023 at 20:33

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.