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
});
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
Best Answer
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.