0

I want to convert a multiband image to array format and export it out of Google Earth Engine in TFRecord format. The number of bands is not fixed and therefore I have to calculate it and then pass its variable content to the export function.

var patch_size = 37;
var NBands = ee.Number(image.bandNames().length()).getInfo();

Export.image.toCloudStorage({
  image: image.toArray(),
  description: outFileName,
  bucket: 'landsat',
  scale: scale,
  region: geometry,
  fileFormat: 'TFRecord',
  formatOptions: {
    patchDimensions: [patch_size, patch_size],
    tensorDepths: [NBands],
    compressed: true
  }
});

The code works without error but I get just a 2KB output .gz file that is obviously wrong and when try to read it I get a parser error. If I substitute a fixed value for NBands it will work well, but I need it to be variable and not fixed. How to do that?

Shahriar49
  • 621
  • 1
  • 5
  • 18

0 Answers0