GEE Python 下载MODIS数据

# -*- coding: cp1252 -*-
# start: 20:30 8/2/2018

import ee
ee.Initialize()

import time
start = time.time()

MODIS = ee.ImageCollection("MODIS/006/MOD11A1")
Boxes = ee.FeatureCollection("users/shshheydari/thesis/AllBoxes")
boxes = Boxes.sort('boxID')

F = open("MODIS_startDates.txt", 'r')
startDates = F.read().splitlines()
endDate = '2018-01-01'

imageCol = MODIS.select('LST_Day_1km').filterDate('2000-01-01', endDate);
scale = imageCol.first().projection().nominalScale().getInfo();

allBlocks = boxes.map(lambda Bbox:
  ee.Feature(imageCol.map(lambda image:
    image.clip(Bbox).reproject('EPSG:4326', None, scale).multiply(0.02) \
    .set({'boxID': Bbox.get('boxID')})
                          )
             )
                      )
boxes2extract = range(0,168);
for i in boxes2extract:
  if startDates[i] != endDate:
    box = ee.Feature(boxes.toList(boxes.size()).get(i))
    box_id = box.get('boxID').getInfo()
    coords = box.geometry().coordinates().getInfo()
    collection =ee.ImageCollection(allBlocks.toList(allBlocks.size()).get(i)) \
    .filter(ee.Filter.gte('system:index', startDates[i]))
    n = collection.size().getInfo()
    if n > 0:
      for j in range(0, n):
        image = ee.Image(collection.toList(n).get(j))
        fname = "MODIS_"+box_id+"-"+image.get('system:index').getInfo()
        print(fname)
        Task = ee.batch.Export.image.toCloudStorage( 
          image= image,
          description= fname,
          bucket= "modis_clips",
          fileNamePrefix= box_id+"/"+fname,
          region= coords,
          scale= scale
        )
        Task.start()
        while Task.status()['state'] != 'COMPLETED':
          pass

end = time.time()
print 'Run time was',end-start,' seconds'

https://gis.stackexchange.com/questions/292466/earth-engine-memory-capacity-exceeded

你可能感兴趣的:(GEE Python 下载MODIS数据)