<jupyter_start><jupyter_text>Donwload a ImageCollection   1._ Install libraries<jupyter_code>!pip3 install earthengine-api;
!pip3 install geemap;
!pip3 install ee;
import sys
sys.path
!pip3 install ipykernel --upgrade
import ee<jupyter_output><empty_output><jupyter_text>2._ Establish connection<jupyter_code>!earthengine authenticate

service_account = '<EMAIL>'
credentials = ee.ServiceAccountCredentials(service_account, 'privatekey.json')
ee.Initialize(credentials)
import ee
try:
  ee.Initialize()
  print('The Earth Engine package initialized successfully!')
except ee.EEException as e:
  print('The Earth Engine package failed to initialize!')
except:
  print("Unexpected error:", sys.exc_info()[0])
  raise<jupyter_output><empty_output><jupyter_text>3._ Example<jupyter_code>import ee
pt = ee.Geometry.Point([-2.40986111110000012, 26.76033333330000019])
region = pt.buffer(10)

col = ee.ImageCollection('LANDSAT/LC08/C01/T1')\
        .filterDate('2015-01-01','2015-04-30')\
        .filterBounds(region)<jupyter_output><empty_output><jupyter_text>4._ Define bands<jupyter_code>bands = ['B4','B5'] #Change it!<jupyter_output><empty_output><jupyter_text>5.  Function to pass to Iterate<jupyter_code>def accumulate(image,img):
  name_image = image.get('system:index')
  image = image.select([0],[name_image])
  cumm = ee.Image(img).addBands(image)
  return cumm

for band in bands:
  col_band = col.map(lambda img: img.select(band)\
                               .set('system:time_start', img.get('system:time_start'))\
                               .set('system:index', img.get('system:index')))
  #  ImageCollection to List           
  col_list = col_band.toList(col_band.size())

  #  Define the initial value for iterate.
  base = ee.Image(col_list.get(0))
  base_name = base.get('system:index')
  base = base.select([0], [base_name])
  
  #  Eliminate the image 'base'.
  new_col = ee.ImageCollection(col_list.splice(0,1))

  img_cummulative = ee.Image(new_col.iterate(accumulate,base))

  task = ee.batch.Export.image.toDrive(
      image = img_cummulative.clip(region),
      folder = 'landsat',
      fileNamePrefix = band,
      scale = 30).start()  
  
  print('Export Image '+ band+ ' was submitted, please wait ...')
img_cummulative.bandNames().getInfo()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1349240780911063, 'fraction_numerical': 0.03427331887201735, 'mean_word_length': 4.570048309178744, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '287088', 'license': 'MIT', 'n_tokens_mistral': 860, 'n_tokens_neox': 802, 'n_words': 144, 'path': 'NASA/Python_codes/GEE_Notebooks/00_scratches/Download_example.ipynb', 'repo_name': 'HNoorazar/Kirti', 'size': '2318'}