【问题标题】:How to export Google Earth Engine images to local files using Python如何使用 Python 将 Google 地球引擎图像导出到本地文件
【发布时间】:2022-06-21 06:44:42
【问题描述】:

我正在使用此代码生成 ge 图像:

image = ee.ImageCollection(satellite) \
            .filterDate(startdate, enddate) \
            .filterBounds(ee.Geometry.Point(centroid[0], centroid[1])) \
            .select(bands) \
            .map(removeClouds) \
            .mean()
type(image)

<class 'ee.image.Image'>

如何将生成的图像保存为本地 GeoTIFF 文件,即存储在运行脚本的桌面计算机中的文件?

【问题讨论】:

标签: python google-earth-engine


【解决方案1】:

您无法将其直接下载到本地目录。正如here 所解释的那样,“由于 Google 地球引擎数据导出是异步的,因此目的地也是基于云的。您可以选择 Google 云端硬盘、Google 云存储或 Earth Engine 中的新资产。”

对于从 Google Drive 中提取图像,this answer 可以为您提供帮助。

【讨论】:

  • 在我看来,这个链接没有显示下载图像。我想把它下载到我的本地高清。它显示了如何将其导出到云端硬盘,而不是之后如何下载它。我可以找到另一种下载方式,但不知道如何获取对应的文件ID。
  • 正如我之前所说,您不能直接将图像下载到本地高清。首先,您应该将图像提取到 Earth Engine 上的驱动器、云或本地驱动器(我的意思是作为 EE 中的新资产)然后,您可以将图像集合下载到本地 HD。你可以在这里找到更多信息,developers.google.com/earth-engine/guides/exporting
【解决方案2】:

不确定 ImageCollection,但您可以通过以下方式将图像下载到本地驱动器:

# Multi-band GeoTIFF file.
url = img.getDownloadUrl({
    'bands': ['B3', 'B8', 'B11'],
    'region': region,
    'scale': 20,
    'format': 'GEO_TIFF'
})
response = requests.get(url)
with open('multi_band.tif', 'wb') as fd:
  fd.write(response.content)

来源:https://developers.google.com/earth-engine/apidocs/ee-image-getdownloadurl#colab-python

【讨论】:

    猜你喜欢
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2019-05-21
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多