用python下载gee影像

用python从GEE导出数据到Google drive
替换compute_wet_days函数,实现导出不同的加工数据

# 读取数据
name = "wdc1_era"
africa = ee.Geometry.Polygon(
[[[-24.64931493978714, 41.307415467346125],
[-24.64931493978714, -39.031243700520264],
[56.913185060213095, -39.031243700520264],
[56.913185060213095, 41.307415467346125]]]
)
years = ["2010", "2012", "2014", "2016", "2018", "2020", "2022"]
def compute_wet_days(precip_array):
threshold = ee.Image.constant(0.001) # 1mm 降水阈值
wet_days = precip_array.map(lambda img: img.gte(threshold))
wet_days_sum = wet_days.reduce(ee.Reducer.sum()).unmask(0, False).rename(name)
return wet_days_sum.toDouble()
for y in years:
start_date = ee.Date(y + "-1-1")
end_date = ee.Date(y + "-12-31")
rainfall_dataset = ee.ImageCollection("ECMWF/ERA5_LAND/DAILY_AGGR") #降雨单位是米
rainfall = rainfall_dataset.select(['total_precipitation_sum']).filterDate(start_date, end_date).filterBounds(africa)
wet_days_image = compute_wet_days(rainfall)
# 导出数据
ee.batch.Export.image.toDrive(
image=wet_days_image,
description=f"{name}_{y}",
folder=f"{name}",
scale=11000,
region=africa,
crs="EPSG:4326",
maxPixels=1e13
).start()
posted @   GeoRepublic  阅读(13)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示