1

I have a problem with my script, I'm trying to download a landsat image, and I'm having some problems with the error:

function maskL8sr(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = (1 << 3);
  var cloudsBitMask = (1 << 5);
  // Get the pixel QA band.
  var qa = image.select('pixel_qa');
  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask);
}

var image = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
                  .filterDate('2016-01-01', '2016-12-31')
                  .filterBounds(bogor)
                  .map(maskL8sr);

var visParams = {
  bands: ['B4', 'B3', 'B2'],
  min: 0,
  max: 3000,
  gamma: 1.4,
};
Map.centerObject(bogor, 10);
Map.addLayer(image.median(), visParams);

Export.image.toDrive({
  image: image,
  description: 'bogor2016',
  scale: 10,
  region: bogor
});

I've checked my script in detail and can't find that I'm doing anything wrong on the calculation part, but I haven't found any related references to help solve my problem.

1

1 Answer 1

2

You are trying to download an imageCollection, so a quick solution is to change the location of the function .median() to create a single image:

var image = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
                  .filterDate('2016-01-01', '2016-12-31')
                  .filterBounds(geometry)
                  .map(maskL8sr)
                  .median();

Here is the code: https://code.earthengine.google.com/69f3f744fcc08f9269afc6b979f79a27

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.