gee下载哨兵2号数据
时间: 2025-06-12 20:53:20 浏览: 42
### 如何使用GEE平台下载Sentinel-2卫星数据
#### 准备工作
为了能够顺利通过Google Earth Engine (GEE) 平台来操作和下载Sentinel-2数据,需先完成一系列准备工作。确保已注册并登录至GEE账号,并安装好Python环境及其对应的API库[^1]。
#### 加载所需模块与初始化连接
在开始编写具体的功能前,加载必要的Python包并与GEE服务器建立通信链接:
```python
import ee
ee.Initialize()
```
#### 定义地理区域及时间范围
根据实际需求设定感兴趣地区(AOI),这里以中国为例;同时设置想要获取影像的时间区间:
```python
aoi = ee.Geometry.Polygon(
[[[108.79, 34.5], [108.79, 34.0],
[110.49, 34.0], [110.49, 34.5]]])
start_date = '2023-01-01'
end_date = '2023-06-30'
```
#### 获取Sentinel-2集合
调用GEE内置函数访问特定时间段内的所有符合条件的Sentinel-2场景列表:
```python
sentinel2_collection = ee.ImageCollection('COPERNICUS/S2') \
.filterBounds(aoi)\
.filterDate(start_date,end_date)
```
#### 应用云掩膜算法
考虑到天气因素的影响,通常还需要去除那些被大量云层覆盖的部分,从而提高最终产品的质量:
```python
def maskS2clouds(image):
qa = image.select('QA60')
cloudBitMask = 1 << 10
cirrusBitMask = 1 << 11
masked_image = image.updateMask(qa.bitwiseAnd(cloudBitMask).eq(0))\
.updateMask(qa.bitwiseAnd(cirrusBitMask).eq(0))
return masked_image.divide(10000)
filtered_sentinel2 = sentinel2_collection.map(maskS2clouds)
```
#### 导出处理过的图像
最后一步就是将经过筛选后的高质量遥感影像保存到本地磁盘上或是上传至云端存储服务中去。下面这段代码展示了如何创建一个任务用来导出指定波段组合而成的一张真彩色图片文件:
```python
task = ee.batch.Export.image.toDrive(**{
'image': filtered_sentinel2.median(),
'description': 'export_s2',
'folder': 'gee_exports',
'region': aoi,
'scale': 10,
'crs': 'EPSG:4326',
'maxPixels': 1e9
})
task.start()
print("Export started.")
```
上述过程不仅简化了从官方渠道手动挑选合适日期段内无云或少云的原始L1C级产品的工作流程,而且借助于云计算的强大能力实现了快速高效的批量自动化处理机制[^2]。
阅读全文
相关推荐


















