按区域检索和下载影像

该案例展示了如何利用平台的矢量文件,进行Sentinel-2 L2A影像的数据检索、筛选、拼接和裁剪操作,并最终将处理后的数据导出至阿里云的'我的数据'。主要步骤包括初始化环境、定义检索区域、执行数据检索和影像导出。

本次分享案例为使用平台内置或自主上传的矢量文件,进行数据的检索(以 Sentine-2 L2A 为例),再进行数据筛选、拼接、裁剪等操作后,将数据导出至我的数据中。

01  初始化环境


import aie
aie.Authenticate()
aie.Initialize()

02   定义矢量区域

使用 FeatureCollection 引用平台内置或自主上传的矢量边界,定义检索数据的区域。利用 aie.Map 构造一个地图组件 Map 对象,通过 aie.Map.addLayer 用于地图可视化渲染不同图层。


region = aie.FeatureCollection('China_Province') \
            .filter(aie.Filter.eq('province', '浙江省')) \
            .geometry()

map = aie.Map(
    center=region.getCenter(),
    height=800,
    zoom=6
)
vis_params = {
    'color': '#00FF00'
}
map.addLayer(
    region,
    vis_params,
    'region',
    bounds=region.getBounds()
)
map

​​​​​03   Sentinel-2数据检索

定义函数 s2_collection ,实现按区域、时间、云量等条件的 Sentinel-2 数据检索,返回哨兵单景 s2 image 和进行镶嵌、裁剪后的 s2 mosaic image 。


def s2_collection(start_date, end_date):
    s2 = aie.ImageCollection('SENTINEL_MSIL2A') \
            .filterBounds(region) \
            .filterDate(start_date, end_date) \
            .filter('eo:cloud_cover<20')
    mosaic_image = s2.median().clip(region)
    return s2, mosaic_image
    
s2, s2_mosaic = s2_collection('2021-04-01', '2022-08-30')

04  影像导出

使用 Export.image.toAsset 将数据导出至平台 我的数据 模块中,可以通过 scale 参数指定导出的分辨率( 单位:米 )。


#导出镶嵌影像
task = aie.Export.image.toAsset(s2_mosaic, 's2_mosaic', 200)
task.start()

#批量实现单景影像的导出
size = s2.size().getInfo()    # 检索得到的影像景数
print(size)

size = 5  
for i in range(size):
    id = s2.toList(count=size).getInfo()[i]['id']
    print(id)
    task = aie.Export.image.toAsset(aie.Image(id), id, 50)
    task.start()

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值