3

For Landsat, I am trying to export a rectangular geometry that I drew for the California Kingfire (prefire) as a GeoTIFF. I am able to successfully export it to my drive, but the image is white. It seems that I might be only looking at one band (maybe?). How can I show the full colored image?

This is my code in the Earth Engine code editor:

var dataset = ee.ImageCollection('USDA/NAIP/DOQQ')
                  .filter(ee.Filter.date('2012-01-01', '2013-12-31'));
var trueColor = dataset.select(['R', 'G', 'B']);
var trueColorVis = {
  min: 0.0,
  max: 255.0,
};
Map.addLayer(trueColor, trueColorVis, 'True Color');

// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
  image: dataset.mean(),
  description: 'Kingfire_RGB_pre',
  scale: 30,
  region: geometry,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  }
});

Any ideas?

1 Answer 1

2

The usual cause of the problem "my export is all black or all white" is that one has used Map.addLayer with visualization parameters to rescale specific bands for RGB, but not done that with the export. The result is an image file that may be suitable for import into GIS software but is not for normal image viewing software — or at least has an extremely low contrast.

You've got a different variation on this problem: the numerical range is OK, but you're exporting a file with floating-point values, and your viewing software is probably assuming they will be between 0.0 and 1.0, not 0.0 and 255.0; hence all the pixels are out of range. Other viewing software might entirely refuse to open the file.

The original data set has type unsigned 8-bit integer, but when you take the mean(), that produces double float values, so you just need to convert it back to integer. You also probably want to select the RGB bands like you did for visualization.

Export.image.toDrive({
  image: dataset.mean().uint8().select(['R', 'G', 'B']),
  ...

However, another option is to use ee.Image.visualize to simply apply the same transformations that Map.addLayer will:

Export.image.toDrive({
  image: trueColor.mean().visualize(trueColorVis),
  ...

Note that I'm starting from your trueColor, not dataset, to pick up the band selections. An equivalent option would be to change trueColorVis to specify bands; this makes it even simpler to ensure that your map and export share the same characteristics. In this version, note that the variable trueColor is gone:

var dataset = ee.ImageCollection('USDA/NAIP/DOQQ')
    .filter(ee.Filter.date('2012-01-01', '2013-12-31'));
var trueColorVis = {
  bands: ['R', 'G', 'B'],
  min: 0.0,
  max: 255.0,
};
Map.addLayer(dataset, trueColorVis, 'True Color');

Export.image.toDrive({
  image: dataset.mean().visualize(trueColorVis),
  description: 'Kingfire_RGB_pre',
  scale: 30,
  region: geometry,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  }
});

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.