0
点赞
收藏
分享

微信扫一扫

AI Earth ——开发者模式案例2:Landsat系列影像数据去云


Landsat 系列数据去云​​¶​​

AIE平台中提供的 Landsat 影像均为 USGS Collection 2 中的数据,该集合使用 QA_PIXEL 波段对云、雪进行描述。因此,可通过位运算和逻辑运算,生成云掩膜,利用 ​​updateMask​​ 函数去除可能是云或者云阴影的区域。此算法适用于 Landsat-5 / 7 / 8 / 9 。

初始化环境​​¶​​

import aie

aie.Authenticate()
aie.Initialize()

定义去云算法​​¶​​

使用 QA_PIXEL 波段进行去云处理。分别缩放SR波段和SP波段像元值,使SR波段像元值尽量在[0,1]之间,ST波段为地表温度的开尔文表示。

def removeLandsatCloud(image):
cloudShadowBitMask = (1 << 4)
cloudsBitMask = (1 << 3)
qa = image.select('QA_PIXEL')
mask = qa.bitwiseAnd(aie.Image(cloudShadowBitMask)).eq(aie.Image(0)).And(qa.bitwiseAnd(aie.Image(cloudsBitMask)).eq(aie.Image(0)))
return image.updateMask(mask)

#参数变换

def applyScaleFactors(image):
opticalBands = image.select('SR_B.').multiply(aie.Image(0.0000275)).add(aie.Image(-0.2))
thermalBands = image.select('ST_B.*').multiply(aie.Image(0.00341802)).add(aie.Image(149.0))
return image.addBands(opticalBands, None, True).addBands(thermalBands, None, True)

Landsat 数据检索​​¶​​

指定区域、时间、云量等,获取目标影像集。检索区域可通过 ​​aie.Geometry​​

#加载研究区
region = aie.FeatureCollection('China_Province') \
.filter(aie.Filter.eq('province', '浙江省')) \
.geometry()

#加载影像
dataset = aie.ImageCollection('LANDSAT_LC08_C02_T1_L2') \
.filterBounds(region) \
.filterDate('2018-01-01', '2018-10-31') \
.filter(aie.Filter.lte('eo:cloud_cover', 20.0))

print(dataset.size().getInfo())

算法调用​​¶​​

对检索到的 dataset 进行去云算法到用并进行数据地图可视化显示。使用 ​​aie.ImageCollection.map​​ 函数可实现对影像集合中的每景影像循环执行指定函数,此处实现对全部检索到的 Landsat8 进行去云处理。

#影像聚合并加载到图层
images_no_cloud = dataset.map(removeLandsatCloud).map(applyScaleFactors)
image = images_no_cloud.mosaic()

vis_params = {
'bands': ['SR_B4', 'SR_B3', 'SR_B2'],
'min': 0.0,
'max': 0.3,
}

map = aie.Map(
center=image.getCenter(),
height=800,
zoom=5
)

map.addLayer(
image,
vis_params,
'True Color(432)',
bounds=image.getBounds()
)

map

去云后的结果:

AI Earth ——开发者模式案例2:Landsat系列影像数据去云_earth

 

举报

相关推荐

0 条评论