0

I am trying to batch download an image collection using Rodrigo E. Principe's tool but I want to download each band seperately by image.select function.

When I download a single band, I get the name of the image, but I want to add name of the band to the image id.

Example of the id I get while downloading band 'B4': 20190731T083609_20190731T084610_T36TVK

Want I want to achieve while downloading band 'B4': 20190731T083609_20190731T084610_T36TVK_B4

This is the code I use for download.


var tile = ee.Geometry.MultiPolygon((([31.8168273934012,40.644794803776],[31.8338683044504, 39.655752572233],[33.1137799145259 ,39.6615512269476],[33.1154430676193, 40.6507988109166])))

var geom= ee.Geometry.Rectangle([31.5, 40.4, 33.1, 39.4])

// Load the Sentinel-2 ImageCollection.
var sentinel2 = ee.ImageCollection("COPERNICUS/S2");

//ImageCollection filtered by date and region
    var filtered = ee.ImageCollection(sentinel2
   .filterDate("2019-07-27", "2019-08-03").filterBounds(geometry));


Map.addLayer(filtered, {bands: ['B4', 'B3', 'B2'], max: 2000}, 'filtered')
Map.centerObject(filtered)

//Clip layer
Map.addLayer(table,{},'140bin')

//clipping Function
var clipimage = function(image) {
return image.clip(table);
};


//Function to Select band
var redband =function(image){
  return image.select('B4')
}



//Select band to download
var red = filtered.map(redband)
Map.addLayer(red,{ max: 2000}, 'red')
Map.centerObject(filtered)

//how many images
var count = filtered.size()
print("Count", count)


//Single Band Batch Download
batch.Download.ImageCollection.toDrive(filtered, '140binclip',   {scale: 10, region: geom.getInfo()})```






1 Answer 1

2

Not sure why you aim to achieve with this, but here is a simple way how you could do that.

//Single Band Batch Download
var bands = filtered.first().bandNames().getInfo();
for (var i = 0; i < bands.length; i++){
  print(bands[i])
  batch.Download.ImageCollection.toDrive(filtered.select(bands[i]), '140binclip'+bands[i],   
                                         {scale: 10, region: geom.getInfo()})
}

Couldn't check it because you code is not reproducible. Use the 'Get Link' button to share the link and assets.

0

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.