I have done a supervised classification. The output is an image collection. I cannot export it in drive. Here is the link
https://code.earthengine.google.com/ebd671bb75dde4892e3a7e14acdc7d4e
var maskL8 = function(image_m) {
var qa = image_m.select('BQA');
var mask = qa.bitwiseAnd(1 << 4).eq(0);
return image_m.updateMask(mask);
};
var image_m = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2018-06-16', '2018-10-15')
.map(maskL8)
.median());
Map.addLayer(image_m, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_m');
var maskL8 = function(image_s) {
var qa = image_s.select('BQA');
var mask = qa.bitwiseAnd(1 << 4).eq(0);
return image_s.updateMask(mask);
};
var image_s = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2018-03-16', '2018-05-15')
.map(maskL8)
.median());
Map.addLayer(image_s, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_s');
var maskL8 = function(image_w) {
var qa = image_w.select('BQA');
var mask = qa.bitwiseAnd(1 << 4).eq(0);
return image_w.updateMask(mask);
};
var image_w = ee.Image(ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterBounds(roi)
.filterDate('2017-11-16', '2018-02-15')
.map(maskL8)
.median());
Map.addLayer(image_w, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'image_w');
var mergedCollection = image_m.addBands(image_s.addBands(image_w));
print('mergedCollection: ', mergedCollection);
Map.addLayer(mergedCollection, {bands: ['B5', 'B4', 'B3'], max: 0.3}, 'mergedCollection');
//merge
var newfc = Waterbody.merge(Wetland).merge(Vegetation).merge(Agricultural).merge(Builtup).merge(BarrenLand);
print(newfc);
//create training data
var bands = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7'];
var training = mergedCollection.select(bands).sampleRegions({
collection: newfc,
properties: ['landcover'],
scale: 30
});
print(training);
//Train the classifier
var classifier = ee.Classifier.cart().train({
features: training,
classProperty: 'landcover',
inputProperties: bands
});
//Run the classification
var classified = mergedCollection.select(bands).classify(classifier);
//Display classification
Map.centerObject(newfc, 11);
Map.addLayer(mergedCollection,
{bands: ['B4', 'B3', 'B2'], max: 0.3},
'Landsat image');
Map.addLayer(classified,
{min: 1, max: 6, palette: ['003EFF', '638A61', 'E34314', 'C3C056', '96E6E5', '95F905' ]},
'classification');
Map.addLayer(newfc)
// Export the image, specifying scale and region.
Export.image.toDrive({
image: classified.select(classified),
description: 'imageToDriveExample',
scale: 500,
region: roi
});
It is showing the following error
Error: Image.select, argument 'bandSelectors': Invalid type. Expected:
List. Actual: Image<[classification]>
Best Answer
The output of
classified
isn't anImageCollection
object, is anImage
object (seeprint(classified);
) and this image has only 1 band. You can use either:or
to export results