python导入哨兵数据_Python 下载哨兵Sentinel数据(Sentinel-1~3)
哨兵數據目前應用廣泛,空間分辨、光譜分辨率都比較高。目前數據下載部分包括官網和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 于廈門
總結
以上是生活随笔為你收集整理的python导入哨兵数据_Python 下载哨兵Sentinel数据(Sentinel-1~3)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: firefox如何载入json文件_如何
- 下一篇: qt5.9.0调试如何查看变量的值_从0