GEE Python API:将图像导出到Google驱动器失败

2024-05-23 22:37:16 发布

您现在位置:Python中文网/ 问答频道 /正文

在一个运行appengine(在本地主机上)的应用程序中使用geepythonapi,我试图将图像导出到googledrive中的文件中。任务似乎启动和完成成功,但没有文件创建在谷歌驱动器。在

我尝试过在GEE代码编辑器中执行等效的javascript代码,这是可行的,文件是在googledrive中创建的。 在python中,我尝试了各种方法来启动任务,但结果总是一样的:任务完成,但没有创建文件。在

我的python代码如下:

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 = {
    'description': 'TEST_todrive_desc',
    'scale': 30,  
    'region': geometry,
    'folder':'GEEtest'
}

task = ee.batch.Export.image.toDrive(landsat, 'TEST_todrive', task_config)
ee.batch.data.startProcessing(task.id, task.config)
# Note: I also tried task.start() instead of this last line but the problem is the same, task completed, no file created. 

# Printing the task list successively 
for i in range(10): 
    tasks = ee.batch.Task.list()
    print(tasks)
    time.sleep(5)

在打印的任务列表中,任务的状态从“就绪”变为“正在运行”,然后是“已完成”。但完成后,我的文件夹“GEEtest”中的Google驱动器中没有创建任何文件(也没有其他任何地方)。在

我做错什么了?在


Tags: 文件the代码testconfigtaskbatchee
1条回答
网友
1楼 · 发布于 2024-05-23 22:37:16

不能在python中直接传递参数字典。您需要使用kwargs约定来通过它(通过web搜索获取更多信息)。基本上,您只需要在task_config参数前面加上双星号,如下所示:

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

然后继续进行(我假设您在下一行中使用task.config而不是{}是一个打字错误)。还请注意,您可以直接查询任务(例如使用task.status()),它可能会提供有关任务失败的时间/原因的更多信息。据我所知,这并不是很好的文档,但是你可以在API code中看到它。在

相关问题 更多 >