A S*_*A S 2 python google-earth-engine
我正在使用Google的Earth Engine API来访问LandSat图像。该程序如下所示,
import ee
ee.Initialize()
Run Code Online (Sandbox Code Playgroud)
加载landsat图像并选择三个波段。
landsat = ee.Image('LANDSAT/LC8_L1T_TOA
/LC81230322014135LGN00').select(['B4', 'B3', 'B2']);
Run Code Online (Sandbox Code Playgroud)
创建代表输出区域的几何。
geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);
Run Code Online (Sandbox Code Playgroud)
导出图像,指定比例和区域。
export.image.toDrive({
image: landsat,
description: 'imageToDriveExample',
scale: 30,
region: geometry
});
Run Code Online (Sandbox Code Playgroud)
它引发以下错误。
Traceback (most recent call last):
File "e6.py", line 11, in <module>
export.image.toDrive({
NameError: name 'export' is not defined
Run Code Online (Sandbox Code Playgroud)
请帮忙。我找不到正确的功能来下载图像。
如果您使用的是python API,则必须使用“ batch”子模块。默认行为是保存到您的Google驱动器。您还可以将边界框指定为坐标列表:
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()
Run Code Online (Sandbox Code Playgroud)
这会在您的GoogleDrive顶层文件夹中生成一个名为“ exportExample.tif”的文件。
另请注意,在python中,每行末尾的分号不是必需的。
| 归档时间: |
|
| 查看次数: |
6069 次 |
| 最近记录: |