小编Mis*_*584的帖子

使用 Python API 将 Google Earth Engine RGB Sentinel-2 图像导出到 Google Drive

这篇文章不是一个问题,而是我一段时间以来一直试图解决的问题的解决方案。希望其他人会发现该代码有用!

我想使用 Python API 将带有从 Google Earth Engine 应用的云屏蔽过滤器的Sentinel-2 卫星图像 ( https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2 ) 导出到我的 Google Drive。然而,并非所有图像都与我感兴趣的几何图形完全重叠,并且云遮罩使某些图像的一部分不可见。因此,我需要创建最接近我感兴趣的日期的图像的马赛克。

最终有效的解决方案如下:

# This is the cloud masking function provided by GEE but adapted for use in Python.
def maskS2clouds(image):
    qa = image.select('QA60')

    # Bits 10 and 11 are clouds and cirrus, respectively.
    cloudBitMask = 1 << 10
    cirrusBitMask = 1 << 11

    # Both flags should be set to zero, indicating clear conditions.
    mask = qa.bitwiseAnd(cloudBitMask).eq(0)
    mask = mask.bitwiseAnd(cirrusBitMask).eq(0)

    return image.updateMask(mask).divide(10000)


# Define …
Run Code Online (Sandbox Code Playgroud)

python google-earth-engine sentinel2

6
推荐指数
1
解决办法
3532
查看次数

标签 统计

google-earth-engine ×1

python ×1

sentinel2 ×1