1

I am struggling with Google Earth Engine Python API version 0.1.238 to export images from the Landsat EVI collection (from 2002 to 2020, but i started with a small sample) to my Google Drive, which are essential to my research.

At first i wanted to add these images directly in QGis, but apparently the version of the Earth Engine plugin of QGis is outdated for such task (i.e. export + impossible to loop the Map.addLayer command).

So I finally built a python script prompting no errors, but my Google Drive folder is still empty. Here is what gives the task.status() command after the task:

{'state': 'READY', 'description': 'myExportImageTask', 'creation_timestamp_ms': 1602830108152, 'update_timestamp_ms': 1602830108152, 'start_timestamp_ms': 0, 'task_type': 'EXPORT_IMAGE', 'id': '2QGWJCVBPUOOCTNFIIDYLKRQ', 'name': 'projects/earthengine-legacy/operations/2QGWJCVBPUOOCTNFIIDYLKRQ'}

How could i make this script work ?

import ee
ee.Initialize()

# USDA NAIP ImageCollection
collection = ee.ImageCollection('LANDSAT/LE07/C01/T1_32DAY_EVI')

# create a roi
polys = ee.Geometry.Polygon(
        [[[37.5, 25.5],
          [40.5, 25.5],
          [40.5, 28.5],
          [37.5, 28.5]]])

# filter the ImageCollection using the roi
naip = collection.filterBounds(polys)

# filter dates
naip_dates = naip.filterDate('2002-04-01', '2002-08-07')
mosaic = naip_dates.mosaic()

# print out the number of images in the ImageCollection
count = naip_dates.size().getInfo()
print("Count: ", count)

# export the ImageCollection to Google Drive
img_lst = naip_dates.toList(100)

for i in range(0, count):
    image = ee.Image(img_lst.get(i))
    name = image.get('system:index').getInfo()
    task = ee.batch.Export.image.toDrive(image=image,
                                         region=polys,
                                         folder='32DAY_EVI',
                                         scale=30,
                                         crs='EPSG:3857')
    task.start()
    print(task.status())

I also tested such simple script to test my Google Drive and still nothing in my folder (not even the creation of the folder itself):

import ee
ee.Initialize()

landsat = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_123032_20140515').select(['B4', 'B3', 'B2'])

geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236])

task_config = {
    'scale': 30,  
    'region': geometry,
    'folder':'GEEtest'
}

task = ee.batch.Export.image.toDrive(landsat, 'TEST_todrive', **task_config)
task.start()

I am wondering if it is not an issue with my Credentials. I did the earthengine authenticate step without any issue, but is there something else to do to link GEE to GDrive ?

0
0

Monday morning, I check my Google Drive, and it is full of data! So my scripts are working (especially the 1st one which is very efficient to extract a collection of images).

My guess is that the servers were down, or overloaded for few days, because now I have a print of task.status() for every image exported (every 10-20s) while before it was only one print for almost an hour.

Sorry for bothering, but at least this script should be useful to some people.

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.