[Python] Sentinelsat模块 - 批量下载Sentinel数据 - 哨兵数据下载方法合集

文章目录

  • [1]下载Sentinel数据的方法
    • [☆]建议:使用IDM软件实现分段下载
    • [1.1]哥白尼数据开放访问中心
    • [1.2]SNAP软件批量下载
    • [1.3]Vertex(美国阿拉斯加卫星设备处)
    • [1.4]USGS(美国地质调查局网站)
  • [2]Sentinelsat包
    • [2.1]介绍与安装
    • [2.2]批量下载哨兵数据
    • [2.3]常见报错

[1]下载Sentinel数据的方法

本节内容引用自:https://blog.csdn.net/lidahuilidahui/article/details/90486402#sentinelsat_83

[☆]建议:使用IDM软件实现分段下载

使用IDM软件实现分段下载:详细教程

[1.1]哥白尼数据开放访问中心

【官网下载】The Copernicus Open Access Hub哥白尼数据开放访问中心

  • 官网说明
  • 【下载受限】购物车中的数据无法实现批量下载,每个账户同时最多只能下载2个产品数据
  • 【历史数据会被下线】使用较少的历史数据会被离线(即LTA)

【长期档案数据(LTA,Long Term Archive)】现阶段使用较少的历史数据会被离线(标记为"Offine"),不让下载,以减少服务器压力

【如何下载已被下线的数据?】

  • 强制下载离线产品,会触发它们重新上线
  • 24小时内必定重新上线,但具体时间不知道
  • 上线后,它们在网上至少保留3天

[1.2]SNAP软件批量下载

【使用SNAP软件批量下载】

  • 下载地址
  • 下载说明:请查看参考文章
  • 缺点:搜索下载通常比较费时,且不能下载被下线的历史数据

[1.3]Vertex(美国阿拉斯加卫星设备处)

【Vertex网站(美国阿拉斯加卫星设备处)】

  • 【提供的数据】Sentinel-1、ALOS-1、Radarsat-1、ERS-1/2

  • 【下载帮助文档】链接

  • 【缺点】速度慢

[1.4]USGS(美国地质调查局网站)

【USGS(美国地质调查局网站)】

  • 【提供的数据】Sentinel-2、Landsat、MODIS、DEM
  • 【下载帮助文档】链接
  • 【依赖】需要Java环境、Bulk Dowload Application(BDA)软件
  • 【缺点】下载流程复杂(从下订单、处理完成到下载,需要接收多个邮件),并且下载速度很慢

[2]Sentinelsat包

[2.1]介绍与安装

【Sentinelsat包介绍】

  • Sentinelsat包提供搜索、下载和检索Sentinel数据的功能
  • 数据来源:哥白尼数据开放访问中心

【相关链接】

  • Github上的Sentinelsat
  • 官方帮助文档

【安装】pip install sentinelsat

[2.2]批量下载哨兵数据

【使用】

  1. 可以在官网中搜索出你想要的产品,然后记下你搜索时设置的参数
  2. 搜索的多边形需要用GeoJSON的形式进行组织(GeoJSON格式的多边形可以在这里获取)
    • 以下例子:将GeoJSON格式搜索区域放到aoi_geojson_fp文件内
# -*- coding: utf-8 -*-
# @Time    : 2019/8/14 15:53
# @Author  : PasserQi
# @Email   : passerqi@gmail.com
# @File    : download
# @Software: PyCharm
# @Version : v1.2.1
# @Desc    : 批量下载哨兵数据
#   1. 下载在线数据--[OK] v1.0.0
#   2. 下载离线数据--[OK] v1.1.0
#   3. 多线程下载
#       --[WARNING] v1.2.1 threading模块未起作用,需要看sentinelsat源代码
#   4. 分段下载from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from collections import OrderedDict
import threading
import os# settings
output_dir = r"F:\下载"               # 数据保存路径
query_excel_fn = "搜索结果.xls"       # 查询结果
success_excel_fn = "success.xls"     # 成功结果
aoi_geojson_fp = r"D:\mycode\GISandPython\2Sentinelsat\xiping.geojson" # 感兴趣区域的GeoJSON文件
query_kwargs = {  # 查询的参数"platformname" :'Sentinel-1',"date" : ('20180101','20181231'),"producttype" : 'SLC',"sensoroperationalmode" : 'IW',# "orbitnumber" : 16302,# "relativeorbitnumber" : 130,# "orbitdirection" : 'ASCENDING',
}
thread_num = 3 # 线程数def products_to_excel(products, fp):infos = {}for item in products:info = products[item]for name in info:value = info[name]if name in infos:infos[name].append(value)else:infos[name] = [value]dict_to_excel(infos, fp)def dict_to_excel(d, fp):import pandas as pddata = [d[key] for key in d]df = pd.DataFrame(data=data).Tdf.columns = d.keys()df.to_excel(fp)threads = []
def download_one(api, product, product_info):# downloadapi.download(product, directory_path=output_dir)# save infosuccess_products[product] = product_infoproducts_to_excel(success_products, success_excel_fp)print('\t[SUCCESS] {}/{}'.format(len(success_products), total))# del products[product] #删除 --> [ERROR] OrderedDict不允许改变# print('\t[surplus] {}'.format(len(products) ))# program variable
success_products = OrderedDict()
products = OrderedDict()
if __name__ == '__main__':query_excel_fp = os.path.join(output_dir, query_excel_fn)success_excel_fp = os.path.join(output_dir, success_excel_fn)# 用户名,密码api = SentinelAPI('账号', '密码')# 搜索footprint = geojson_to_wkt( read_geojson(aoi_geojson_fp)) # 读取geojson文件,获取足迹kw = query_kwargs.copy() # 设置查询参数,足迹,平台,日期,产品类型,返回的是以产品id为key的复合字典results = api.query(footprint, **kw)products.update(results)# uitotal = len(products)print("[Total] {} ".format(total) )# save fileproducts_to_excel(products, query_excel_fp)# 先激活离线产品try:print("===触发离线产品上线===")cnt = 1for product in products:product_odata = api.get_product_odata(product)if not product_odata['Online']:print("[激活离线产品 {}] {}".format(cnt, product_odata['date']))api.download(product, output_dir)  # 触发重新上线cnt += 1except:print("[抱歉] 该账户激活离线产品的次数不足")pass# 开始下载print("===开始下载===")while len(success_products)!=total:for product in products:product_odata = api.get_product_odata(product)if product_odata['Online']:  #在线# 打印产品文件名print('[Online] {} {}'.format(product_odata['date'], product_odata['title']) )# 下载# print("线程数 {}".format(threading.active_count()) ) #debugif threading.active_count()<=thread_num: #线程没有起作用t = threading.Thread(download_one(api, product, products[product]) )t.start()else:# 离线数据不下载,等待上线print("[Offine] {}".format(product_odata['date'] ))

[2.3]常见报错

【10054】OpenSSL.SSL.SysCallError: (10054, ‘WSAECONNRESET’)

  • 10054 对方已经关闭连接。

【Requests exceed user quota】sentinelsat.sentinel.SentinelAPILTAError: HTTP status 403 Forbidden: Requests for retrieval from LTA exceed user quota

  • 每个账户请求离线产品有限,一般20幅


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部