【问题标题】:Python GEE: Download Landsat collection with cloud maskPython GEE:下载带有云遮罩的 Landsat 集合
【发布时间】:2022-10-09 03:15:43
【问题描述】:

我在 GEE 的代码编辑器上有一个 JavaScript,它允许我下载一组直接应用了云过滤器的 Landsat 图像(这意味着我只下载云覆盖率低于一定百分比的图像)。 我想将代码翻译成 Python 但我不知道如何处理自定义云函数: 在 JavaScript 中,直接在 ee.collection() 命令中调用不带任何变量的云条件(少于 x% 的云将在集合中)。在Python中,我不知道如何使它工作,因为还没有变量,看来我必须先下载图像,然后应用云百分比计算(如果不符合则转储我的图像)要求)。

有没有办法在 Python 上下载已经根据云量过滤的 Landsat 图像?

我的 JavaScript 代码是:

var geometry: Polygon, 4 vertices
type: 
Polygon
coordinates: 
List (1 element)
0: 
List (5 elements)
0: 
[-141.0073440277409,59.69885769939182]
1: 
[-140.12569119570966,59.69885769939182]
2: 
[-140.12569119570966,60.16125006608516]
3: 
[-141.0073440277409,60.16125006608516]
4: 
[-141.0073440277409,59.69885769939182]
0: 
-141.0073440277409
1: 
59.69885769939182
geodesic: 
false
var cloudMaskL457 = function(image) {
  var qa = image.select('pixel_qa');
  // If the cloud bit (5) is set and the cloud confidence (7) is high
  // or the cloud shadow bit is set (3), then it's a bad pixel.
  var cloud = qa.bitwiseAnd(1 << 5)
                  .and(qa.bitwiseAnd(1 << 7))
                  .or(qa.bitwiseAnd(1 << 3));
  // Remove edge pixels that don't occur in all bands
  var mask2 = image.mask().reduce(ee.Reducer.min());
  return image.updateMask(cloud.not()).updateMask(mask2);
};

var l5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
                  .filterDate('1984-01-01', '2012-05-05')
                  .map(cloudMaskL457)
                  .filterBounds(aoi)
                  .map(function(a){
                    return a.set('year', ee.Image(a).date().get('year'))
                  })

Ps:我已经使用了具有特定内置功能的 Sentinel-2 下载代码。我没有为 Landsat 找到类似的东西。

S2_collection = ee.ImageCollection('COPERNICUS/S2').filterBounds(polytest).filter(ee.Filter.lessThanOrEquals('CLOUDY_PIXEL_PERCENTAGE', 10)).filter(ee.Filter.date(sdate, edate))

【问题讨论】:

    标签: javascript python filter google-earth-engine


    【解决方案1】:

    这个链接可以帮助你,它适用于我在 python 中的代码,我在 python 中做同样的事情

    https://jayaramhariharan.com/py_gee_tools/_modules/gee_python_tools/cloudmask.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 2017-11-25
      • 2019-03-15
      • 2020-04-10
      • 1970-01-01
      • 2015-12-18
      相关资源
      最近更新 更多