相关文章推荐
严肃的面包  ·  google ...·  2 年前    · 
严肃的面包  ·  Google Earth ...·  2 年前    · 
严肃的面包  ·  Google Earth ...·  2 年前    · 
严肃的面包  ·  google earth map ...·  2 年前    · 

如何使用谷歌地球引擎的python API下载图片

6 人关注

我正在使用谷歌的地球引擎API来访问陆地卫星图像。 该程序如下所示。

import ee
ee.Initialize()

加载一张陆地卫星图像并选择三个波段。

landsat = ee.Image('LANDSAT/LC8_L1T_TOA
/LC81230322014135LGN00').select(['B4', 'B3', 'B2']);

创建一个代表出口区域的几何体。

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

输出图像,指定比例和区域。

 export.image.toDrive({
    image: landsat,
    description: 'imageToDriveExample',
    scale: 30,  
    region: geometry

it throws the following error.

Traceback (most recent call last):
File "e6.py", line 11, in <module>
export.image.toDrive({
NameError: name 'export' is not defined

请帮助。我无法找到正确的功能来下载图片。

1 个评论
请不要添加大的字体。同时编辑你的代码格式...
python
google-earth-engine
A S
A S
发布于 2016-08-30
5 个回答
Ben DeVries
Ben DeVries
发布于 2019-12-12
已采纳
0 人赞同

如果你使用python API,你必须使用 "批处理 "子模块。默认行为是保存到你的google drive。你也可以把你的包围盒指定为一个坐标列表。

llx = 116.2621
lly = 39.8412
urx = 116.4849
ury = 40.01236
geometry = [[llx,lly], [llx,ury], [urx,ury], [urx,lly]]
task_config = {
    'description': 'imageToDriveExample',
    'scale': 30,  
    'region': geometry
task = ee.batch.Export.image(landsat, 'exportExample', task_config)
task.start()

这应该在你的GoogleDrive顶部文件夹中生成一个名为 "exportExample.tif "的文件。

还要注意的是,每行末尾的分号在python中是不必要的。

如何选择你的驱动器的一个文件夹?
在task_config dict中使用 "文件夹 "关键字。
MikeS
MikeS
发布于 2019-12-12
0 人赞同

To build on Ben的回答 ,你也可以使用。

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

从你原来的帖子中,但在它下面添加以下一行,以便坐标以正确的格式出现在task_config-->Region field:

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

它可以防止你到这里时出现 "task_config "的格式不匹配。

task = ee.batch.Export.image(landsat, 'exportExample', task_config)

这将允许你使用API中的给定函数,但它将以这样一种方式提取坐标,即你可以用Ben上面建议的方法使用它们。

G07cha
G07cha
发布于 2019-12-12
0 人赞同