哨兵数据目前应用广泛,空间分辨、光谱分辨率都比较高。目前数据下载部分包括官网和Python程序下载。
其中哨兵1和2数据下载网上已经有非常详细的记录,链接如下:Python中使用sentinelsat包自动下载Sentinel系列数据_lidahuilidahui的博客-CSDN博客blog.csdn.net
我对python代码进行了些微调整,用起来更方便一些。这里面主要还是需要安装库文件sentinelsat
pip install sentinelsat
哨兵1和2数据下载具体代码如下:
def download_sentinel_data(user_name,password,website,foot_print,start_date,end_date,platformname,producttype,max_cloud):
api = SentinelAPI(user_name,password,website)
footprint = geojson_to_wkt(read_geojson(foot_print))
products = api.query(footprint,
date=(start_date, end_date),
platformname=platformname,
producttype =producttype,
cloudcoverpercentage = (0, max_cloud))
print(len(products))
for product in products:
product_info = api.get_product_odata(product)
# print(product_info)
print(product_info['title'])
api.download(product)
这是我随便设定的数据时间,检索的数据结果,这数据还是太大,不过在我这下载速度还挺快的,结果如下:
但是该程序在下载哨兵3会报错,原因是数据文件的详细信息有所不同,导致你在提取文件信息的时候会有偏差,因此,我重新修订了哨兵3数据的下载方式。
库文件都是一样的,同样的还是需要制作足迹文件:以'Changjiang_map.geojson’为例
产品类型本次选择‘OL_2_LRR___’,这个根据需要自行更改。
具体代码如下:
from sentinelsat.sentinel import SentinelAPI, read_geojson, geojson_to_wkt
import logging
import os, sys
def download_sentinel_data(user_name,password,website,foot_print,start_date,end_date,platformname,producttype,max_cloud):
api = SentinelAPI(user_name,password,website)
footprint = geojson_to_wkt(read_geojson(foot_print))
products = api.query(footprint, date=(start_date,end_date),platformname = platformname,cloudcoverpercentage = max_cloud,producttype= producttype)
print("PRODUCT SIZE: "+ str(api.get_products_size(products)))
fp=api.to_geojson(products)
# print(fp)
for entry in fp["features"]:
product_id= entry["properties"]["id"]
print (entry["properties"]["identifier"])
print (entry["properties"]["id"])
print (entry["properties"]["beginposition"])
api.download(product_id)
sys.exit()
if __name__ == '__main__':
user_name = ''
password = ''
website = 'https://scihub.copernicus.eu/apihub/'
foot_print = ''
start_date = '20190122'
end_date = '20200124'
platformname = 'Sentinel-3'
producttype = 'OL_2_LRR___'
max_cloud = 60
download_sentinel_data(user_name,password,website,foot_print,start_date,end_date,platformname,producttype,max_cloud)
数据检索结果如下,本次只是示例,我只下载一个数据文件,不过下载速度嗖嗖的:
本次只是一个示例,证明了Python下载哨兵3数据的可能,我并没有比对过检索数据量的正确与否,感兴趣的可以自行尝试。
欢迎交流,祝好!
2020.11.23 于厦门