ArcEngine 获取HDF文件中的子文件

HDF格式,为影像常用的格式。里面有许多的子文件,在用AE打开影像的时候,按照AE常规的方式打开影像的方式是行不通的。先把HDF中需要的文件,提出来,再按常规的打开影像的方式打开。下面代码为提出HFD文件中的子集:

public IRasterDataset HDFSubdataset(IRasterDataset rasterDataset, int subsetID)
{
  //Some raster formats can contain multiple subdatasets inside a single file, for example the HDF format.
  //This sample code shows how one can retrieve the HDF subdatasets using the IRasterDatasetJukebox interface.
  //rasterDataset: represents a raster dataset from a HDF4 file
  IRasterDatasetJukebox hdfDataset= (IRasterDatasetJukebox)rasterDataset;
  IRasterDataset subDatasset;
  int datasetCount = hdfDataset.SubdatasetCount;
  if (subsetID < datasetCount)
    {
     hdfDataset.Subdataset = subsetID;
     subDatasset = (IRasterDataset)hdfDataset;
     return subDatasset;
    }
  else { return rasterDataset; }
}

然后就打开subDataset就可以了。。

原文地址:https://www.cnblogs.com/myyouthlife/p/2383492.html