geemap学习笔记015:下载哨兵2号(Sentinel-2)数据

前言

使用GEE下载数据应该是最常见的功能了,今天就介绍一下如何使用geemap下载哨兵2号(Sentinel-2)数据,分别包括自己画感兴趣,以及利用Assets中的shp文件进行下载。

1 自己画感兴趣下载哨兵2号影像

import geemap
import ee

Map = geemap.Map(height=800)
collection = (
    ee.ImageCollection('COPERNICUS/S2_SR')
    .filterDate('2021-01-01', '2022-01-01')
    .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 5))
) #获取哨兵2号数据,过滤2021年一年的数据,过滤云量小于5的影像

image = collection.median() #这一行代码很有意思,是对覆盖同一区域的影像取均值,以消除云的影响
  
vis = {
    'min': 0.0,
    'max': 3000,
    'bands': ['B4', 'B3', 'B2'],
} #设置可视化参数

Map.setCenter(119.276370, 37.774189, 11) #设置中心
Map.addLayer(image, vis, 'Sentinel-2')
Map

自己画的roi区域
image.png

feature = Map.draw_last_feature #获取自己画的roi
roi = feature.geometry() #返回给定要素的几何形状
print(roi.getInfo()) #打印roi信息

geemap.ee_export_image_to_drive(
  image.select('B4', 'B3', 'B2'), description='huanghe', folder='export', region=roi, scale=90
) #选择4、3、2三个波段,裁剪roi区域,并以分辨率scale进行导出到drive中

2 利用Assets中的shp文件进行下载

roi_ass = ee.FeatureCollection('projects/******/assets/shape/yantai_qu')
print(roi_ass.getInfo())
Map.addLayer(roi_ass, {}, 'Land cover') #展示数据
Map.centerObject(roi_ass,10)
Map

Assets中的shp文件加载显示
image.png

geemap.ee_export_image_to_drive(
  image.select('B4', 'B3', 'B2'), description='yantai', folder='export', region=roi_ass.geometry(), scale=90
) #选择4、3、2三个波段,裁剪roi_ass区域,并以分辨率scale进行导出到drive中,注意roi_ass.geometry()

3 出图结果展示

请添加图片描述

后记

大家如果有地信遥感方面的问题需要请教或者有项目需要合作,可以在闲 鱼软件的用户中搜索:遥感GIS工作室,请认准头像,谢谢。

  • 13
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一些示例代码,演示如何将 Sentinel-2 和 Sentinel-1 数据进行融合: 1. 利用Python的sentinelsat库下载Sentinel-2和Sentinel-1数据: ```python from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt # 登录sentinelsat账 api = SentinelAPI('username', 'password', 'https://scihub.copernicus.eu/dhus') # 下载Sentinel-2数据 footprint = geojson_to_wkt(read_geojson('path/to/footprint.geojson')) products = api.query(footprint, platformname='Sentinel-2', cloudcoverpercentage=(0, 30), producttype='S2MSI1C') # 下载Sentinel-1数据 products = api.query(footprint, platformname='Sentinel-1', polarisationmode='VV VH', producttype='GRD', orbitdirection='ASCENDING') ``` 2. 使用Python的gdal库读取和处理Sentinel-1数据: ```python from osgeo import gdal # 读取Sentinel-1数据 s1_vv = gdal.Open('path/to/sentinel1_vv.tif') s1_vh = gdal.Open('path/to/sentinel1_vh.tif') # 将Sentinel-1数据转换为dB单位 s1_vv_db = 10 * np.log10(s1_vv.ReadAsArray()) s1_vh_db = 10 * np.log10(s1_vh.ReadAsArray()) # 对Sentinel-1数据进行滤波和校正 # ... # 将Sentinel-1数据重采样到Sentinel-2的分辨率 # ... # 将Sentinel-1数据Sentinel-2数据进行融合 # ... ``` 3. 使用Python的scikit-image库将Sentinel-2和Sentinel-1数据进行融合: ```python from skimage import exposure # 将Sentinel-2数据进行拉伸和直方图匹配,使其与Sentinel-1数据的动态范围一致 s2_rgb = exposure.rescale_intensity(s2_rgb, in_range=(0, 0.3), out_range=(0, 1)) s2_rgb_matched = exposure.match_histograms(s2_rgb, s1_vv_db) # 将Sentinel-1数据Sentinel-2数据进行加权融合 s1_weight = 0.6 s2_weight = 0.4 fused = (s1_weight * s1_vv_db + (1 - s1_weight) * s1_vh_db) * s2_weight + (1 - s2_weight) * s2_rgb_matched ``` 这只是一些示例代码,具体的融合方法和参数需要根据具体的应用场景进行调整和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值