gpt4 book ai didi

python - GEE Python API : Export image to Google Drive fails

转载 作者:行者123 更新时间:2023-12-05 05:11:05 30 4
gpt4 key购买 nike

在与 App Engine 一起运行的应用程序中使用 GEE Python API(在本地主机上),我试图将图像导出到 Google Drive 中的文件。该任务似乎已成功启动并完成,但未在 Google Drive 中创建任何文件。

我已尝试在 GEE 代码编辑器中执行等效的 javascript 代码,这行得通,该文件是在 Google Drive 中创建的。在 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)

在打印的任务列表中,任务的状态从READY变为RUNNING,然后是COMPLETED。但完成后,在我的文件夹“GEEtest”(或其他任何地方)的 Google Drive 中没有创建任何文件。

我做错了什么?

最佳答案

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

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

然后按原样继续(我假设您在下一行中使用 task.config 而不是 task_config 是错字)。另请注意,您可以直接查询任务(例如使用 task.status()),它可能会提供有关任务失败的时间/原因的更多信息。据我所知,这没有很好的记录,但你可以在 API code 中阅读它。 .

关于python - GEE Python API : Export image to Google Drive fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55882991/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com