1 旧方法
网上有如下方法将IRaster转换为IRasterDataset;但此方法转换不完全,只转换了第一个波段Item(0)。
IRaster raster = rasterLayer.Raster;
IRasterBandCollection rasterBandCollection = raster as IRasterBandCollection;
IRasterBand rasterBand = rasterBandCollection.Item(0);
IRasterDataset rasterDataset = rasterBand as IRasterDataset;
2 最佳方法
使用新接口IRaster2
IRaster raster = rasterlayer.Raster;
IRaster2 raster2 = raster as IRaster2;
IRasterDataset rasterDataset = raster2.RasterDataset;