Wechat: yu389741| Email: gisdqy@163.com

Shop:https://www.giserdqy.com/shop

使用GDAL对HDF数据进行校正


在使用HDF的数据时,首先要对其进行校正处理。比如MODIS数据中,有个去除蝴蝶结现象。一般出现这种情况会在低分辨率卫星数据中(个人理解),比如气象卫星,海洋卫星等,这类数据一般的数据分辨率都很低,几百米到几公里,主要用于大范围的检测。
下面以MODIS数据为例,简单说明一下蝴蝶结现象出现的原因。

MODIS图像在其扫描线宽度方向由扫描条带组成,条带宽度为10(1000米分辨率)、20(500米分辨率)和40个象素(250米分辨率),所以地球的球面特性会导致扫描带两端产生数据的重叠现象,将扫描带组成遥感图像后即形成所谓的“蝴蝶结”效应(bowtie现象),如以1公里分辨率为例,每条扫描线1354个象素,其象素尺寸在星下点为1╳1公里,而随着扫描角的增大和地球曲率的影响象素尺寸逐渐增大,当扫描角为55度,其象素尺寸变为沿扫描方向4.83公里 、沿轨道方向2.01公里的大小,象素尺寸随扫描角的变化规律如图-1所示。这种象素尺寸的几何形变造成两个现象,一是边沿象素对象区域的重叠现象,而且越靠近边沿,象素重叠现象越严重;二是沿扫描方向图象的压缩失真,如图2所示。


图1 MODIS数据蝴蝶结现象产生的原因


图2 MODIS蝴蝶结现象

蝴蝶结的处理一般有两种:Bowtie处理算法主要有“星历表法”和“非星历表法”两种。“星历表法”是根据卫星的星历表生成标准地理网格,将数据按照其地理坐标投影到该网格上来进行匹配,在地理定标的同时消除bowtie现象。International MODIS/AIRS Processing Package (IMAPP)和NASA GSFC MODIS Level 1均使用的这种方法。
Terra卫星的星历表由TDRSS 星上导航系统(TDRSS Onboard Navigation System,TONS)生成,随着科学数据流的第二类工程组包(Type 2 Engineering Group packets)广播到地面站。
Aqua卫星没有星上导航系统,因此星历表需要通过地面控制站上传到卫星然后再下传给其他地面站,或者使用估计的星历表(精确的星历表在几个小时的延迟之后才可能获得)。
由于Terra和Aqua的MODIS L1B数据产品均不包含星历表,因此,用户无法使用星历表对MODIS L1B数据进行bowtie处理。对于Aqua卫星的MODIS数据,使用估计的星历表进行数据处理会影响bowtie处理的准确性,使用精确的星历表则无法实现实时处理。

对于气象卫星(静止卫星)、海洋卫星的数据的校正,一般也是使用的“星历表法”进行处理。对于HDF数据来说,这个星历表其实是两幅单波段的浮点型数据,其像元值是经度或者纬度值。下面以一个MODIS的数据为例(MOD021KM.A2010287.0250.005.2010287121743.hdf)进行说明。

首先我们使用gdalinfo工具查看这个MODIS数据的信息,输出的信息如下:

Driver: HDF4/Hierarchical Data Format Release 4
Files: F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf
Size is 512, 512
Coordinate System is `'
Metadata:
  % Dead Detector EV Data=0, ……此处省略…… ,0, 0
  % EV Data Not Calibrated=0, 0, ……此处省略……, 0, 0
  % EV Data Where Cannot Compute BG DN=0, 0, ……此处省略……, 0, 0
  % EV Data Where Nadir Door Closed=0, 0, ……此处省略……, 0, 0
  % L1A EV All Scan Data are Missing=0
   ……此处省略一大长串……
  SHORTNAME=MOD021KM
  Solar Irradiance on RSB Detectors over pi=511.46, ……此处省略……116.183, 116.183
  SOUTHBOUNDINGCOORDINATE=27.4153536499348
  VERSIONID=5
  WESTBOUNDINGCOORDINATE=106.240739628195
Subdatasets:
  SUBDATASET_1_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB
  SUBDATASET_1_DESC=[15x2030x1354] EV_1KM_RefSB MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_2_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB_Uncert_Indexes
  SUBDATASET_2_DESC=[15x2030x1354] EV_1KM_RefSB_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_3_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_Emissive
  SUBDATASET_3_DESC=[16x2030x1354] EV_1KM_Emissive MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_4_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_Emissive_Uncert_Indexes
  SUBDATASET_4_DESC=[16x2030x1354] EV_1KM_Emissive_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_5_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_250_Aggr1km_RefSB
  SUBDATASET_5_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_6_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_250_Aggr1km_RefSB_Uncert_Indexes
  SUBDATASET_6_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_7_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_250_Aggr1km_RefSB_Samples_Used
  SUBDATASET_7_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB_Samples_Used MODIS_SWATH_Type_L1B (8-bit integer)
  SUBDATASET_8_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_500_Aggr1km_RefSB
  SUBDATASET_8_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_9_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_500_Aggr1km_RefSB_Uncert_Indexes
  SUBDATASET_9_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_10_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_500_Aggr1km_RefSB_Samples_Used
  SUBDATASET_10_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB_Samples_Used MODIS_SWATH_Type_L1B (8-bit integer)
  SUBDATASET_11_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:Height
  SUBDATASET_11_DESC=[406x271] Height MODIS_SWATH_Type_L1B (16-bit integer)
  SUBDATASET_12_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:SensorZenith
  SUBDATASET_12_DESC=[406x271] SensorZenith MODIS_SWATH_Type_L1B (16-bit integer)
  SUBDATASET_13_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:SensorAzimuth
  SUBDATASET_13_DESC=[406x271] SensorAzimuth MODIS_SWATH_Type_L1B (16-bit integer)
  SUBDATASET_14_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:Range
  SUBDATASET_14_DESC=[406x271] Range MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_15_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:SolarZenith
  SUBDATASET_15_DESC=[406x271] SolarZenith MODIS_SWATH_Type_L1B (16-bit integer)
  SUBDATASET_16_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:SolarAzimuth
  SUBDATASET_16_DESC=[406x271] SolarAzimuth MODIS_SWATH_Type_L1B (16-bit integer)
  SUBDATASET_17_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:gflags
  SUBDATASET_17_DESC=[406x271] gflags MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_18_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_Band26
  SUBDATASET_18_DESC=[2030x1354] EV_Band26 MODIS_SWATH_Type_L1B (16-bit unsigned integer)
  SUBDATASET_19_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_Band26_Uncert_Indexes
  SUBDATASET_19_DESC=[2030x1354] EV_Band26_Uncert_Indexes MODIS_SWATH_Type_L1B (8-bit unsigned integer)
  SUBDATASET_20_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":0
  SUBDATASET_20_DESC=[406x271] Latitude (32-bit floating-point)
  SUBDATASET_21_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":1
  SUBDATASET_21_DESC=[406x271] Longitude (32-bit floating-point)
  SUBDATASET_22_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":2
  SUBDATASET_22_DESC=[15x2030x1354] EV_1KM_RefSB (16-bit unsigned integer)
  SUBDATASET_23_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":3
  SUBDATASET_23_DESC=[15x2030x1354] EV_1KM_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_24_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":4
  SUBDATASET_24_DESC=[16x2030x1354] EV_1KM_Emissive (16-bit unsigned integer)
  SUBDATASET_25_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":5
  SUBDATASET_25_DESC=[16x2030x1354] EV_1KM_Emissive_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_26_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":6
  SUBDATASET_26_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB (16-bit unsigned integer)
  SUBDATASET_27_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":7
  SUBDATASET_27_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_28_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":8
  SUBDATASET_28_DESC=[2x2030x1354] EV_250_Aggr1km_RefSB_Samples_Used (8-bit integer)
  SUBDATASET_29_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":9
  SUBDATASET_29_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB (16-bit unsigned integer)
  SUBDATASET_30_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":10
  SUBDATASET_30_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_31_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":11
  SUBDATASET_31_DESC=[5x2030x1354] EV_500_Aggr1km_RefSB_Samples_Used (8-bit integer)
  SUBDATASET_32_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":12
  SUBDATASET_32_DESC=[406x271] Height (16-bit integer)
  SUBDATASET_33_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":13
  SUBDATASET_33_DESC=[406x271] SensorZenith (16-bit integer)
  SUBDATASET_34_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":14
  SUBDATASET_34_DESC=[406x271] SensorAzimuth (16-bit integer)
  SUBDATASET_35_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":15
  SUBDATASET_35_DESC=[406x271] Range (16-bit unsigned integer)
  SUBDATASET_36_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":16
  SUBDATASET_36_DESC=[406x271] SolarZenith (16-bit integer)
  SUBDATASET_37_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":17
  SUBDATASET_37_DESC=[406x271] SolarAzimuth (16-bit integer)
  SUBDATASET_38_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":18
  SUBDATASET_38_DESC=[406x271] gflags (8-bit unsigned integer)
  SUBDATASET_39_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":19
  SUBDATASET_39_DESC=[2030x1354] EV_Band26 (16-bit unsigned integer)
  SUBDATASET_40_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":20
  SUBDATASET_40_DESC=[2030x1354] EV_Band26_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_41_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":21
  SUBDATASET_41_DESC=[16x10] Noise in Thermal Detectors (8-bit unsigned integer)
  SUBDATASET_42_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":22
  SUBDATASET_42_DESC=[16x10] Change in relative responses of thermal detectors (8-bit unsigned integer)
  SUBDATASET_43_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":23
  SUBDATASET_43_DESC=[203x16x10] DC Restore Change for Thermal Bands (8-bit integer)
  SUBDATASET_44_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":24
  SUBDATASET_44_DESC=[203x2x40] DC Restore Change for Reflective 250m Bands (8-bit integer)
  SUBDATASET_45_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":25
  SUBDATASET_45_DESC=[203x5x20] DC Restore Change for Reflective 500m Bands (8-bit integer)
  SUBDATASET_46_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":26
  SUBDATASET_46_DESC=[203x15x10] DC Restore Change for Reflective 1km Bands (8-bit integer)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

上面的元数据有很多,全部贴出来太多,省略了很多。在下面的子数据集中,可以发现有两个子数据集比较特别,第20个和第21个。如下:

  SUBDATASET_20_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":0
  SUBDATASET_20_DESC=[406x271] Latitude (32-bit floating-point)
  SUBDATASET_21_NAME=HDF4_SDS:UNKNOWN:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":1
  SUBDATASET_21_DESC=[406x271] Longitude (32-bit floating-point)

从上面的描述信息中就可以看到,这两个分别就是经度查找表和纬度查找表,通过这两个坐标查找表就可以对每个行列号的数据进行定位。在GDAL中,对使用位置查找表进行校正的算法已经进行了封装。具体的算法有空再写,今天只是怎么使用GDAL提供的工具来对MODIS的数据进行处理做个说明。

我们还是以上面的这个数据为例。对里面的第一个子数据集进行校正处理。使用的工具是gdalwarp(PS,这个工具在我的博客中出现的频率很高,另外还有一个是gdalinfo)。

 SUBDATASET_1_NAME=HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB
  SUBDATASET_1_DESC=[15x2030x1354] EV_1KM_RefSB MODIS_SWATH_Type_L1B (16-bit unsigned integer)

上面就是第一个子数据集的路径和描述信息。HDF数据的子数据集路径,就是SUBDATASET_X_NAME=后面的部分,全部都是。比如我要查看这个子数据集的信息,使用下面的代码:

gdalinfo "HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB"

输出的信息如下,一共有15个波段,使用Envi打开显示的图像如图3所示(使用R:15,G:14, B:13彩色组合显示)。

Driver: HDF4Image/HDF4 Dataset
Files: F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf
       F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf.aux.xml
Size is 1354, 2030
Coordinate System is `'
GCP Projection = 
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]
GCP[  0]: Id=, Info=
          (2.5,2.5) -> (108.323760986328,48.8070602416992,0)
GCP[  1]: Id=, Info=
          (122.5,2.5) -> (113.807312011719,48.6253700256348,0)
GCP[  2]: Id=, Info=
          (242.5,2.5) -> (117.034530639648,48.3954010009766,0)
 ……此处省略很多个点……
GCP[143]: Id=, Info=
          (1322.5,1982.5) -> (128.73503112793,28.1821708679199,0)
Metadata:
  % Dead Detector EV Data=0,  ……此处省略……, 0, 0, 0
  % EV Data Not Calibrated=0, 0,  ……此处省略……0, 0, 0
  % EV Data Where Cannot Compute BG DN=0,  ……此处省略……, 0, 0, 0
  % EV Data Where Nadir Door Closed=0, 0, 0,  ……此处省略…… 0, 0, 0
   ……此处省略一大长串……
  units=none
  valid_range=0, 32767
  VERSIONID=5
  WESTBOUNDINGCOORDINATE=106.240739628195
Geolocation:
  LINE_OFFSET=2
  LINE_STEP=5
  PIXEL_OFFSET=2
  PIXEL_STEP=5
  SRS=GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]
  X_BAND=1
  X_DATASET=HDF4_EOS:EOS_SWATH_GEOL:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:Longitude
  Y_BAND=1
  Y_DATASET=HDF4_EOS:EOS_SWATH_GEOL:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:Latitude
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 2030.0)
Upper Right ( 1354.0,    0.0)
Lower Right ( 1354.0, 2030.0)
Center      (  677.0, 1015.0)
Band 1 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 2 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 3 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 4 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 5 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 6 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 7 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 8 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 9 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 10 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 11 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 12 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 13 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 14 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none
Band 15 Block=1354x738 Type=UInt16, ColorInterp=Gray
  Description = Earth View 1KM Reflective Solar Bands Scaled Integers
  NoData Value=65535
  Unit Type: none

图3 第一个子数据集未校正前(R:15,G:14, B:13)

接下来我们使用gdalwarp来对上面这个子数据集进行处理。由于坐标查找表是使用经纬度的,所以处理的结果数据也是WGS84的经纬度数据。在使用gdalwarp是需要指定输出图像的投影,我们手动指定为WGS84(EPSG:EPSG:4326)。处理的命令行代码如下:

gdalwarp.exe --config GDAL_DATA "C:\gdal\data" -geoloc -t_srs EPSG:4326 "HDF4_EOS:EOS_SWATH:"F:\Data\HDF\MOD021KM.A2010287.0250.005.2010287121743.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB" F:\Data\HDF\MOD021KM.tif

上面的–config GDAL_DATA “C:\gdal\data”就是这是GDAL的data目录,也可以使用环境变量进行设置。主要目的是为了将后面的坐标系EPSG代码转为GDAL认识的wkt格式。执行的过程如图4所示。

图4 gdalwarp处理hdf数据处理过程


使用Envi打开上面处理的结果,截图如图5所示,依旧使用RGB(15,14,13)波段组合显示。可以看到,输出的图像已经有投影信息了,是一个WGS84的坐标。Envi中显示的效果如图6所示,在ArcMap中打开,并和全球的shp图层叠加显示的效果如图7所示。从图7中可以看出,gdal处理的结果的准确性还是蛮高的,尤其是在渤海湾处可以很明显的看出来。


图5 处理后的数据以及RGB波段组合

图6 经过gdal处理后的数据

图7 处理后的数据和全球的矢量叠加显示的效果

参考资料:

1、http://liangshzh0816.blog.163.com/blog/static/3477676200892010294314/

2、http://wenku.baidu.com/view/7491f6fb700abb68a982fb9e.html

3、http://trac.osgeo.org/gdal/wiki/rfc4_geolocate

转载自:https://blog.csdn.net/liminlu0314/article/details/8623607