天天看點

python導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)

哨兵資料目前應用廣泛,空間分辨、光譜分辨率都比較高。目前資料下載下傳部分包括官網和Python程式下載下傳。

其中哨兵1和2資料下載下傳網上已經有非常詳細的記錄,連結如下:Python中使用sentinelsat包自動下載下傳Sentinel系列資料_lidahuilidahui的部落格-CSDN部落格​blog.csdn.net

python導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)

我對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)

這是我随便設定的資料時間,檢索的資料結果,這資料還是太大,不過在我這下載下傳速度還挺快的,結果如下:

python導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)
python導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)

但是該程式在下載下傳哨兵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導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)
python導入哨兵資料_Python 下載下傳哨兵Sentinel資料(Sentinel-1~3)

本次隻是一個示例,證明了Python下載下傳哨兵3資料的可能,我并沒有比對過檢索資料量的正确與否,感興趣的可以自行嘗試。

歡迎交流,祝好!

2020.11.23 于廈門