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)

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