1

What are the possible reasons for this error? This is the code:

Map.addLayer(PuntoQuellaveco1);
Map.addLayer(operaciones);
Map.addLayer(Abast);


 var image = ee.ImageCollection('COPERNICUS/S2')
 .filterBounds(PuntoQuellaveco1)
 .filterDate('2016-07-01','2016-08-31')
 .sort('CLOUD_COVER', false);

var conteo = image.size();
print('conteo de imágenes', conteo);

var mejorImagen = ee.Image(image.sort('CLOUD_COVER').first());

print('La primera con menos nubosidad', mejorImagen);

Map.addLayer(mejorImagen, {bands: ['B4', 'B3', 'B2'], max: 3000}, 'image');

var fechaAdquirida = mejorImagen.get('DATE_ACQUIRED');

print('Fecha adquirida', fechaAdquirida);


 Export.image.toDrive({
  image: mejorImagen,
  description: 'imageToDriveExample',
  scale: 10,
  region: Abast
   });

The variables are already created, They just can't be copied because of this:

enter image description here

2

If you have a look at Sentinel 2 bands you'll find that all bands are type unsigned int 16 except for QA20 that is unsigned int 32, that band is causing the issue.

S2 bands

You can solve it in different ways, but I post here what I think is what you need:

var image = ee.ImageCollection('COPERNICUS/S2')
              .filterBounds(PuntoQuellaveco1)
              .filterDate('2016-07-01','2016-08-31')
              .sort('CLOUD_COVER', false);

var conteo = image.size();
print('conteo de imágenes', conteo);

var mejorImagen = ee.Image(image.sort('CLOUD_COVER').first());

print('La primera con menos nubosidad', mejorImagen);

Map.addLayer(mejorImagen, {bands: ['B4', 'B3', 'B2'], max: 3000}, 'image');

var fechaAdquirida = mejorImagen.get('DATE_ACQUIRED');

print('Fecha adquirida', fechaAdquirida);

// Keep only 'B' bands
// Me quedo solo con las bandas 'B'
mejorImagen = mejorImagen.select('B.+')

Export.image.toDrive({
  image: mejorImagen,
  description: 'imageToDriveExample',
  scale: 10,
  region: Abast
   });

Or you could make QA20 and unsigned int 16 to match the others:

// Cast band's types to uint16
// Transformo los tipos de dato de las bandas a uint16
mejorImagen = mejorImagen.toUint16()
  • Thanks, that worked. Do you know how to download all the bands not in a composite one but each band separately? – Alvaro Morales Oct 29 '18 at 15:32
  • You could make a client side for loop for each band calling Export each time – Rodrigo E. Principe Oct 29 '18 at 16:09
  • I did this and It seemed it's right. mejorImagen = mejorImagen.select(['B1','B2','B3','B4','B5','B6','B7']) – Alvaro Morales Oct 29 '18 at 16:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.