Python程序教程

您现在的位置是:首页 >  Python

当前栏目

python读取modis数据

python,读取,modis,数据
2025-03-28 09:01:05 时间

大家好,又见面了,我是你们的朋友全栈君。

本期记录只上干活,废话不多说,主要是后面与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)

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/139247.html原文链接:https://javaforall.cn