ArcObjects 波段合成

可以用地理处理

ClassCompositeBandsCreates a single raster dataset from multiple bands and can also create a raster dataset using only a subset of bands.

也可以不用,贴代码了

public static IRaster toColor(IRaster raster, ITable redTable, ITable greenTable, ITable blueTable)
{
IReclassOp reclassOp
= new RasterReclassOpClass();
IGeoDataset red
= reclassOp.Reclass(raster as IGeoDataset, redTable, "FromField",
"ToField", "OutField", true);
IGeoDataset green
= reclassOp.Reclass(raster as IGeoDataset, redTable, "FromField",
"ToField", "OutField", true);
IGeoDataset blue
= reclassOp.Reclass(raster as IGeoDataset, redTable, "FromField",
"ToField", "OutField", true);

IRasterBandCollection rasterBandCollection;
IRaster newRaster
= new RasterClass();
rasterBandCollection
= newRaster as IRasterBandCollection;

IRasterBandCollection tempRasterBandCollection;
IRasterBand tempRasterBand;

tempRasterBandCollection
= red as IRasterBandCollection;
tempRasterBand
= tempRasterBandCollection.Item(0);
rasterBandCollection.AppendBand(tempRasterBand);

tempRasterBandCollection
= green as IRasterBandCollection;
tempRasterBand
= tempRasterBandCollection.Item(0);
rasterBandCollection.AppendBand(tempRasterBand);

tempRasterBandCollection
= blue as IRasterBandCollection;
tempRasterBand
= tempRasterBandCollection.Item(0);
rasterBandCollection.AppendBand(tempRasterBand);

return newRaster;
}

  保存的时候一定要注意,保存成TIFF格式,保存成GRID格式,会报错Stack name *** is too long,是GRID不支持多波段吧

            ISaveAs2 save = MyRasterTools.toColor(raster, rTable, gTable, bTable) as  ISaveAs2;
IDataset outRasterDS
= save.SaveAs("multibands.tif", rasterWorkspace as IWorkspace, "TIFF");
System.Runtime.InteropServices.Marshal.ReleaseComObject(outRasterDS);

  最后一句释放保存的结果,要不然之后从Workspace打开,会报错

转载于:https://www.cnblogs.com/ahalc/archive/2011/07/23/2115023.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值