1

I'm new to Google Earth Engine and Google AI Platform. A model was previously trained and published to AI platform and be imported to Earth Engine for image classification. The trained model successfully classified landcover in the specified area into 5 classes, however, I faced some problems when I was trying to export the classified images to my Google Drive.

Below is the script I have so far. An error message of 'Cannot export array bands' jumped out when I tried to export the result.

How can I export the labeled image and the probability maps?

var model_1985 = ee.Model.fromAiPlatformPredictor({
  projectId : 'most-308413',
  modelName : 'Mostcnn_1985',
  version : 'v0',
  inputTileSize : [100, 100],
  proj : ee.Projection('EPSG:4326').atScale(30),
  fixInputProj : true,
  outputBands : {'landclass': {
  'type': ee.PixelType.float(),
  'dimensions': 1}
}
});

var predictions_1985 = model_1985.predictImage(array_image_1985);
var label_1985 = predictions_1985.arrayArgmax().arrayGet([0]).rename('label');
var probabilities_1985 = predictions_1985.arrayFlatten([["builtup","barren","cultivated","water","vegetation"]]);

Export.image.toDrive({
  image: predictions_1985,
  description: 'dl_classified_1985',
  folder: 'GEE',
  region: Clip_Extent,
  scale:20,
  crs: 'EPSG:4326',
})
1
  • I have no idea what that error means. However Have You checked whether Your prediction works? You can try to examine Your classification via ´print(probabilities_1985)´. The code is not executed strictly linearly in the Google Earth Engine. There might even be a problem creating the image....
    – Jonas
    Apr 17, 2021 at 15:52

1 Answer 1

0

You've done the hard work but looks like you are trying to export the wrong object - you should set image: probabilities_1985 in the Export.image.toDrive command (rather than image: predictions_1985)

I had also been tripped up by this - each pixel of the image returned by predictImage is a 1D array rather than a scalar value, so you have to unpack each value into a separate band using arrayFlatten, even if your prediction only returns a single value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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