使用GDAL库发现不能打开IRSP6的数据,不过看GDAL提供的文件格式里面却是支持IRSP6的数据的,具体可以参考网页http://www.gdal.org/frmt_fast.html。下面图1是一个IRSP6数据的目录结构,由一个hdr和四个ges数据组成,hdr是FAST格式的主文件,ges就是每个波段的裸数据。
图1 P6数据目录结构
首先使用gdalinfo工具输出看看能不能读取。gdalinfo输出的结果如图2所示,可以看出gdal是不支持这种数据的。
图2 gdalinfo打开查看信息
下面是hdr文件中的内容,
PRODUCT ID =ID201104-01 LOCATION =134/03000F ACQUISITION DATE =20090101 SATELLITE =IRS P6 SENSOR =AWIFS SENSOR MODE =PLD LOOK ANGLE = 0.00 LOCATION = ACQUISITION DATE = SATELLITE = SENSOR = SENSOR MODE = LOOK ANGLE = LOCATION = ACQUISITION DATE = SATELLITE = SENSOR = SENSOR MODE = LOOK ANGLE = LOCATION = ACQUISITION DATE = SATELLITE = SENSOR = SENSOR MODE = LOOK ANGLE = PRODUCT TYPE =MAP ORIENTED PRODUCT SIZE =FULL SCENE TYPE OF PROCESSING =SYSTEMATIC RESAMPLING =CC VOLUME #/# IN SET =01/01 PIXELS PER LINE =18284 LINES PER BAND =17248/17248 START LINE # = 1 BLOCKING FACTOR = 1 RECORD LENGTH =36568 PIXEL SIZE = 56.00 OUTPUT BITS PER PIXEL =10 ACQUIRED BITS PER PIXEL =10 BANDS PRESENT =2345 PRODUCT CODE =STLC00GBD VERSION NO =IRSP6DPSV1R2 ACQUISITION TIME =02:52:16:357 GENERATING COUNTRY =CHINA GENERATING AGENCY =RSGS GENERATING FACILITY =DPFP6 PRODUCT ENDIAN =LITTLE REV CBIASES AND GAINS IN THE BAND ORDER AS ON THIS TAPE 0.000000000000000 52.340000000000003 0.000000000000000 40.750000000000000 0.000000000000000 28.425000000000001 0.000000000000000 4.645000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 SENSOR GAIN STATE = 8 9 8 9 SENSOR STATE =GOOD GEOMETRIC DATA MAP PROJECTION =LCC ELLIPSOID =WGS_84 DATUM =WGS_84 USGS PROJECTION PARAMETERS = 6378137.000000000000000 6356752.314199999906123 55.209495199333482 51.035107167553996 129.000000000000000 10.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 0.000000000000000 UL = 1174202.5250E 571139.1862N -681580.807 5708788.219 UR = 1344237.7839E 573316.7699N 342323.193 5708788.219 LR = 1333947.1849E 485402.4658N 342323.193 4742900.219 LL = 1194514.8374E 483619.3269N -681580.807 4742900.219 CENTER = 1262709.6744E 531850.3922N -169628.807 5225844.219 9142 8624 OFFSET = 128 ORIENTATION ANGLE = 0.00 SUN ELEVATION ANGLE =13.1 SUN AZIMUTH ANGLE =169.7 ALTITUDE =829002.00000 HEADING ANGLE = 207.006210
仔细查看帮助文档,发现对于IRS数据,由于hdr文件中没有记录波段数据的文件名称,所以只能猜测可能的波段数据名称,GDAL目前猜的规则是:
<header>.<ext> <header>.1.<ext> <header>.2.<ext> ... or <header>.<ext> band1.<ext> band2.<ext> ... or <header>.<ext> band1.dat band2.dat ... or <header>.<ext> imagery1.<ext> imagery2.<ext> ... or <header>.<ext> imagery1.dat imagery2.dat ...
从上面可以看出,猜测的几种数据就是没有<header>_1.ges这种类型,于是就ges修改对应的源码,源码位于GDAL_HOMEfrmts aw/fastdataset.cpp。主要修改下面几个方面:
1、Open函数中,数据的生产单位原来是写死的“GENERATING AGENCY =EUROMAP”,而这个数据却是"GENERATING AGENCY =EUROMAP"。所以将原来的
if (strstr(pszHeader, "GENERATING AGENCY =EUROMAP")!= NULL)
修改为:
if ((strstr(pszHeader, "GENERATING AGENCY =EUROMAP")!= NULL) || (strstr(pszHeader, "GENERATING AGENCY =RSGS")!= NULL))2、Open函数中最下面,原来只判断了WGS84,而这个数据里面是WGS_84,所以再加上这个判断。修改后的代码如下:
if ( EQUAL( pszTemp, "WGS84" ) || EQUAL( pszTemp, "WGS_84" ) )3、FOpenChannel函数中,加上我们这个数据的波段数据类型,即<header>_1.ges。在原来的default后面加上一个,如下所示:
default: pszChannelFilename = CPLFormFilename( pszDirname, CPLSPrintf( "%s.%d", pszPrefix, iFASTBand ), pszSuffix ); if ( OpenChannel( pszChannelFilename, iBand ) ) break; pszChannelFilename = CPLFormFilename( pszDirname, CPLSPrintf( "%s_%d.ges", pszPrefix, iFASTBand ), NULL ); if ( OpenChannel( pszChannelFilename, iBand ) ) break;保存上面的内容,然后重新编译,使用gdalinfo输出的信息为:
图3 gdalinfo工具查看输出的信息