3

I am trying to export the TIFF file from Google Earth Engine, but the exported file appears black.

var image = ee.Image(ee.ImageCollection("COPERNICUS/S2")
    .filterBounds(roi)
    .filterDate('2021-06-01', '2021-06-30')
    .sort('CLOUD_COVER')
    .first()
    .clip(roi))
  
  Map.addLayer(image, {bands: ['B4', 'B3', 'B2'],min:0, max: 3000}, 'True colour image')

var classNames = heterogeneitybaresoil.merge(vegetation);
print(classNames)

var bands = ['B2', 'B3', 'B4','B8', ];
var training = image.select(bands).sampleRegions({
  collection: classNames,
  properties: ['landcover'],
  scale: 30
});
print(training);

var classifier = ee.Classifier.smileCart().train({
  features: training,
  classProperty: 'landcover',
  inputProperties: bands
});


//Run the classification
var classified = image.select(bands).classify(classifier);

//Display classification
Map.centerObject(classNames, 11);
Map.addLayer(classified,
{min: 0, max: 1, palette: ['green','red']},
'classification');


// Create a task that you can launch from the Tasks tab.
Export.image.toDrive({
  image: classified,
  description: 'Akamas',
  scale: 30
});

enter image description here

this is how looks like my exported tiff

the script of the above (in order to help you to run it) https://code.earthengine.google.com/f8bc253d6c67799c92012441177173a0?hideCode=true

6
  • Add a screenshot of the exported raster. Commented Aug 19, 2021 at 15:14
  • Try visualizing the image in a GIS (e.g., ArcGIS, QGIS) Commented Aug 19, 2021 at 15:30
  • i have already open the tiff file in ArcGis Pro but file appears black too Commented Aug 19, 2021 at 16:55
  • the code of the script (if this help to run it) : code.earthengine.google.com/… Commented Aug 19, 2021 at 18:13
  • It's only all black because you haven't symbolized it (the Windows image viewer can't do this). Use unique values symbology in your GIS software. It's mostly 0s with a small patch of 1s (i.sstatic.net/jP43z.png).
    – user2856
    Commented Aug 19, 2021 at 22:05

1 Answer 1

3

If you want to export the red/green image, call Image.visualize on the output, using the same visualization parameters you're using to display it. Otherwise, you're Exporting an image of 0s and 1s, which when you display it will appear black and almost-black.

Export.image.toDrive({
  image: classified.visualize({min: 0, max: 1, palette: ['green','red']}),
  description: 'Akamas',
  scale: 30
});
1
  • thank you for your answer Mr. Noel Commented Aug 21, 2021 at 13:03

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.