python遥感数据有偿处理_使用Python处理hdf格式遥感卫星文件(如modis, viirs)

很多的遥感数据源(特别是NASA家的)都是用hdf格式承载的,比如著名的modis啊viirs,用Python也可以直接处理,从此和ENVI说拜拜!

Requestpython2.7(貌似这个pyhdf包在Python3下不能用)

conda环境

然后conda安装pyhdf(一定要按照下面的代码安装,直接conda install会装不上)

conda install -c conda-forge pyhdf

使用

下面以viirs文件为例说明其使用方法

读取hdf数据

from pyhdf.SD import SD, SDC

file_name = 'VNP09_NRT.A2018347.0324.001.hdf'

file = SD(file_name, SDC.READ) #加载数据

print file.info()

会返回(19,55), 19代表着VIIRS包含的19个波段的数据集。

获得每个波段的名称

datasets_dic = file.datasets()

for idx,sds in enumerate(datasets_dic.keys()):

print idx,sds

会得到:

0 QF2 Surface Reflectance

1 QF1 Surface Reflectance

2 375m Surface Reflectance Band I3

3 375m Surface Reflectance Band I2

4 375m Surface Reflectance Band I1

5 QF3 Surface Reflectance

6 QF7 Surface Reflectance

7 QF5 Surface Reflectance

8 750m Surface Reflectance Band M10

9 750m Surface Reflectance Band M11

10 QF6 Surface Reflectance

11 750m Surface Reflectance Band M8

12 QF4 Surface Reflectance

13 750m Surface Reflectance Band M7

14 750m Surface Reflectance Band M4

15 750m Surface Reflectance Band M5

16 750m Surface Reflectance Band M2

17 750m Surface Reflectance Band M3

18 750m Surface Reflectance Band M1

获得各个波段储存的数据:

sds_obj = file.select('750m Surface Reflectance Band M1') # select sds

data = sds_obj.get() # get sds data

print data

可获得

[[-28672 -28672 -28672 ..., -28672 -28672 -28672]

[-28672 -28672 -28672 ..., -28672 -28672 -28672]

[ 3664 3701 3710 ..., 10797 10804 10894]

...,

[ 6044 6913 6981 ..., 8519 8532 8562]

[-28672 -28672 -28672 ..., -28672 -28672 -28672]

[-28672 -28672 -28672 ..., -28672 -28672 -28672]]

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值