1

Below is my code and it runs perfectly but when I run the unsubmitted task in gee,it gives this error:

Error: Image.setDefaultProjection, argument 'image': Invalid type. Expected type: Image. Actual type: ImageCollection. (Error code: 3)

var dataset = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
      .filterBounds(geometry)
      .filterDate('2019-11-17', '2020-03-31')


// Applies scaling factors.
function applyScaleFactors(image) {
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0);
  var saturationMask = image.select('QA_RADSAT').eq(0);
  
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBands, null, true)
              .updateMask(qaMask)
              .updateMask(saturationMask);
}

dataset = dataset.map(applyScaleFactors);

var visualization = {
  bands: ['SR_B4', 'SR_B3', 'SR_B2'],
  min: 0.0,
  max: 0.3,
};


Map.addLayer(dataset, visualization, 'True Color (432)');

Export.image.toDrive({ 
  image: dataset,
  description: 'Landsat8_for_NDBI',
  scale: 10, 
  maxPixels: 1e13, 
  region: geometry 
});

Can you help me to bypass this?

1
  • 1
    In your script, dataset is not an image but an image collection. You cannot pass an ImageCollection to image parameter of toDrive function. Commented May 23, 2022 at 12:22

1 Answer 1

0

Use the awesome geetools from Rodrigo E. Principe for exporting an ImageCollection to Drive:

var batch = require('users/fitoprincipe/geetools:batch');

batch.Download.ImageCollection.toDrive(dataset,'Some_folder',{
  scale: 10, 
  maxPixels: 1e13, 
  region: geometry 
});
8
  • I had an error :In users/fitoprincipe/geetools:batch Line 133: collection.size is not a function Commented May 23, 2022 at 15:52
  • @AugustusInyang check the parenthesis, imageCollection and folder are out of curly brackets. That error is because the function didn't load an imageCollection. It works for me: code.earthengine.google.com/6d8fd26868308b75839634e32b235399
    – aldo_tapia
    Commented May 23, 2022 at 16:11
  • Sorry I actually corrected it, but the issue is the page keeps freezing and becomes unresponsive Commented May 23, 2022 at 16:14
  • @AugustusInyang maybe the study area is too big or the date range takes too many scenes. Try it with a small date range first for debugging purposes
    – aldo_tapia
    Commented May 23, 2022 at 16:53
  • I guess you are right, because after waiting for a couple of time, lots of task started loading, and the issue now is that, after downloading one of the task then imported to Arcmap, the landsat image is a no data Commented May 24, 2022 at 10:35

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.