1

I am trying to download Landsat 5 Band 6 using Google Earth Engine. When I run the code I am getting the following error: Error: Invalid argument: 'image' must be of type Image. I found on this post that I was trying to export an ImageCollection instead of a single image. I also found this post but the getDownloadURL is not working. I would like to ask, because I am new to GEE how can I download a single band? Below it's the code:

   var sub_geom = region.geometry();
    var sub_region = JSON.stringify(sub_geom.bounds(1).getInfo().coordinates);

Map.addLayer(sub_geom);
var cloudMaskL457 = function(image) {
  var qa = image.select('pixel_qa');
  // If the cloud bit (5) is set and the cloud confidence (7) is high
  // or the cloud shadow bit is set (3), then it's a bad pixel.
  var cloud = qa.bitwiseAnd(1 << 5)
                  .and(qa.bitwiseAnd(1 << 7))
                  .or(qa.bitwiseAnd(1 << 3));
  // Remove edge pixels that don't occur in all bands
  var mask2 = image.mask().reduce(ee.Reducer.min());
  return image.updateMask(cloud.not()).updateMask(mask2);
};
//Import Landsat Image
var L7200508NDVI = ee.Image(ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
.filterDate('1995-01-01', '1995-01-31')
.map(cloudMaskL457)
.filterBounds(sub_geom)
.mean());

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: L7200508NDVI,
  description: 'imageToDriveExample',
  scale: 120,
  region: sub_geom
});
  • 1
    Your code runs successfully for me, although I would have used a different region geometry. I suppose you've checked that your region overlaps some images? Also, it outputs an 11-band image. To get only band 6, similar to how you select the pixel_qa band, you can L7200508NDVI.select("B6") to get band 6. – phloem Jul 17 at 21:30
  • 1
    Same here, it runs with a different region. – Rodrigo E. Principe Jul 18 at 2:41
  • The code runs successfully but when I try to download the images I get the error I mentioned. Because I am struggling for some time now to download the Band 6, can you please specify at which line I should include L7200508NDVI.select("B6")? Thank you – niktziok Jul 18 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.