python讀取modis數據

本期記錄只上幹活,廢話不多說,主要是後面與HEG配合使用,實現一系列研究與反演操作。

python環境:Python 3.5.2 +Pycharm

模塊包:pyhdf

安裝方法(命令行輸入)

pip install pyhdf

一、獲取hdf數據集:

from pyhdf.SD import SD
HDF_FILR_URL = "E:\Persona_project\Py-Program\RS\modis\MOD021KM.A2018092.0300.061.2018092134259.hdf"
file = SD(HDF_FILR_URL)
info=file.info()#數據集個數
print(info)
ds_dict=file.datasets()#所有數據集名稱
for idx, sds in enumerate(ds_dict.keys()):
    print(idx, sds)

二、獲取每個數據集數據:

# -*- coding:utf-8 -*-
# author:
from pyhdf.SD import SD
HDF_FILR_URL = "E:\Persona_project\Py-Program\RS\modis\MOD021KM.A2018092.0300.061.2018092134259.hdf"
file = SD(HDF_FILR_URL)
EV_1KM_Emissive = file.select('EV_1KM_RefSB').get()
print(EV_1KM_Emissive.shape)

三、獲取每個數據集屬性:

# -*- coding:utf-8 -*-
# author:
from pyhdf.SD import SD
HDF_FILR_URL = "E:\Persona_project\Py-Program\RS\modis\MOD021KM.A2018092.0300.061.2018092134259.hdf"
file = SD(HDF_FILR_URL)
EV_1KM_Emissive = file.select('EV_1KM_RefSB')
attributes = EV_1KM_Emissive.attributes()#獲取屬性
radiance_scales = attributes['radiance_scales']#輻亮度縮放尺度
radiance_offsets = attributes['radiance_offsets']##輻亮度偏移值
reflectance_scales = attributes['reflectance_scales']#反射率縮放尺度
reflectance_offsets = attributes['reflectance_scales']#反射率偏移值
print(radiance_scales)
print(radiance_offsets)
print(reflectance_scales)
print(reflectance_offsets)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章