gee计算太湖水体面积、哨兵数据、otsu大津法、2016-2023年、折线图输出,代码
时间: 2024-12-19 07:26:45 浏览: 133
GEE (Google Earth Engine) 是一个基于云的数据分析平台,主要用于处理卫星遥感数据。要在GEE中计算太湖水体面积,结合哨兵数据,并使用Otsu阈值分割(一种图像二值化方法),以及统计2016年至2023年的变化,你可以按照以下步骤编写Python脚本:
```python
import ee
ee.Authenticate() # 登录你的GEE账户
ee.Initialize()
# 定义太湖区域
taihu = ee.Geometry.Point([120.2945, 31.7854]) # 假设这是太湖中心点,实际可能需要更精确的边界
# 加载哨兵数据
s2 = ee.ImageCollection('COPERNICUS/S2')
s2_filtered = s2.filterDate('2016-01-01', '2023-12-31') \
.filterBounds(taihu)
# 对每个时间步长进行MNDWI(Modified Normalized Difference Water Index)计算,增强水体信号
mndwi = s2_filtered.map(lambda img: img.normalizedDifference(['B8', 'B11']))
# 应用Otsu阈值分割找出水体部分
def otsu(image):
threshold = image.select('B8').reduce(ee.Reducer.otsu())
return image.updateMask(image.select('B8').gt(threshold))
water_masks = mndwi.map(otsu)
# 计算每个时间步水体面积并加总
total_area = water_masks.reduce(ee.Reducer.sum()).multiply(water_masks.geometry().area())
# 输出折线图
chart = total_area.plot(lineWidth=3)
chart.setOptions({'title': '太湖水体面积(单位:平方公里)'})
chart.exportToDrive(filename='TaiHu/AreaOverTime.png')
阅读全文
相关推荐


















