简介
开始之前需要安装sentinelsat库:
pip install sentinelsat
代码比较简单,只需要sentinelsat库中的SentinelAPI连接到Sentinel数据Hub,需要在官网手动获取下载链接:
代码
在这里from sentinelsat import SentinelAPI
# 提供有效的用户名和密码
username = "your"
password = "your"
# 文件保存路径
directory_path = 'data'
# 连接到Sentinel数据Hub
api = SentinelAPI(username, password, 'https://scihub.copernicus.eu/dhus')
product_url = "https://scihub.copernicus.eu/dhus/odata/v1/Products('3a2ef878-4256-4d9a-baa5-0aa46c54d244')/$value" # 在Cart中找到数据的下载链接
product_id = "3a2ef878-4256-4d9a-baa5-0aa46c54d244" # product_url中单引号内的字符
# 下载单个数据文件
api.download(product_id, directory_path) # 输入从下载连接中获取的product_id
# 或者,下载多个数据文件
#product_urls = ["product_id1", "product_id2", "product_id3"] # 替换为要下载的多个Sentinel数据的product_id列表
#api.download_all(product_ids, directory_path)插入代码片
结果