0

Error:

ERROR---Error: Image.clipToBoundsAndScale, argument 'input': Invalid type. Expected type: Image. Actual type: ImageCollection. (Error code: 3)

THE SCRIPT:

Map.addLayer(roi)
Map.centerObject(roi, 10)
var img = ee.ImageCollection("COPERNICUS/S2_SR")
              .filterDate('2021-10-01','2021-10-25')
              
              .filterBounds(roi);

var calcLSWI = function(image) {
  var lswi = image.expression(
       '(NIR - SWIR) / (NIR+SWIR)', {
      'NIR': image.select('B8').multiply(0.0001),
      'SWIR': image.select('B11').multiply(0.0001),
 }).rename('LSWI');
  return image.addBands(lswi);
}
var LSWI = img.map(calcLSWI).select('LSWI')
print(LSWI)
Map.addLayer(LSWI)
var Chart = ui.Chart.image.seriesByRegion({
  imageCollection: LSWI,
  regions: roi,
  reducer: ee.Reducer.mean(), //type of reduction. See ee.Reducers for other kinds of reductions
  seriesProperty: 'NAME'  //property of roi to display in map
})
  .setOptions({
    title: 'LSWI',
    vAxis: {title: 'LSWI', maxValue: 1, minValue: -1},
    hAxis: {title: 'date'},
  })

print(Chart)
Export.image.toDrive({
image: LSWI,
description: 'LSWI_VAISHALI',
folder: 'classification',
scale: 30,
fileFormat: 'GeoTIFF',
    });

Link to code

1

1 Answer 1

0

The error message is pretty self-explanatory. You can only export a single image at the time, but instead you are trying to export an imageCollection made up of 20 separate images. You can either export them individually with a loop or calculate a mean or median and export that.

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.