1、问题背景:
最近项目中获得了一份全球云分布图,客户要求把云显示在全球地图上,出现云的效果,如下图所示:
【全球云分布图】
【世界地图云示意图】
2、解决思路
咨询专业的业务人员,建议我测试下试试地图透明通道,地图底色设置为白色,设置透明通道来完成这个效果,赶紧来试,先用PIE的波段合成功能,成功的将3波段的世界地图.tiff和全球的云分布图合并成一个四波段的带云分布的世界地图,赶紧设置RGBA波段,果然出现了想要的效果。
【波段合成】
【设置渲染方式】
3、实现代码
下一步就是代码实现这个功能了,首先调用波段合成算法,再设置RGBA渲染,大功告成了。
// 波段组合算法调用 PIE.CommonAlgo.BandCombination_Exchange_Info info = new PIE.CommonAlgo.BandCombination_Exchange_Info(); string path = @"D:DataWorld.tif"; IRasterDataset rDataset = DatasetFactory.OpenDataset(path, OpenMode.ReadOnly) as IRasterDataset; string path1 = @"D:DataCC_2018082615.tif"; IRasterDataset rDataset1 = DatasetFactory.OpenDataset(path1, OpenMode.ReadOnly) as IRasterDataset; info.m_vecFileptr = new List<IRasterDataset> { rDataset, rDataset1 }; List<int> list1 = new List<int> { 0, 1, 2 }; List<int> list2 = new List<int> { 0 }; info.bands = new List<List<int>> { list1, list2 }; info.tstrfile = @"D:DataCloudPic.tif"; info.m_strFileTypeCode = "GTiff"; PIE.CommonAlgo.Interestregion interestregion = new PIE.CommonAlgo.Interestregion(); interestregion.SetRegion(0, 0, rDataset.GetRasterYSize(), rDataset.GetRasterXSize()); info.regioninfo = new List<PIE.CommonAlgo.Interestregion> { interestregion, interestregion }; info.m_iOutRangeCrossType = 0; PIE.SystemAlgo.ISystemAlgo algo = PIE.SystemAlgo.AlgoFactory.Instance().CreateAlgo("PIE.CommonAlgo.dll", "PIE.CommonAlgo.BandCombinationAlgo"); if (algo == null) return; PIE.SystemAlgo.ISystemAlgoEvents algoEvents = algo as PIE.SystemAlgo.ISystemAlgoEvents; algo.Name = "波段合成"; algo.Params = info; bool result = PIE.SystemAlgo.AlgoFactory.Instance().ExecuteAlgo(algo); ILayer layer = PIE.Carto.LayerFactory.CreateDefaultLayer(@"D:DataCloudPic.tif"); IRasterRGBRender rRGBRender = new RasterRGBRender(); rRGBRender.SetBandIndices(0, 1, 2); rRGBRender.UseAlphaBand = true; rRGBRender.AlphaBandIndex = 3; //设置rasterRender IRasterRender rasterRender = rRGBRender as IRasterRender; IRasterLayer rasterLayer = layer as IRasterLayer; rasterLayer.Render = rasterRender; m_HookHelper.ActiveView.FocusMap.AddLayer(layer); m_HookHelper.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);