zoukankan      html  css  js  c++  java
  • ArcGIS Engine 9.2 打开多波段栅格数据

    在用AE打开多波段栅格数据时,如果自己的观察,AE的IRasterBandCollection只是打开了多波段的三个波段,而对于其他的波段并没有打开,这个我觉得应该是ArcGIS公司的bug问题。我现在做的这点就遇到了这个问题,我要分析栅格数据的第四个波段,可以没有数据怎么分析呢。最后我想到了一个折中的办法,对于多波段栅格数据,前三个波段用于显示颜色,像普通打开栅格数据一样,添加图层,这个没有什么难度。然后循环打开后面的波段,一个波段一个图层,然后添加到map控件中,并设置其透明度为100,即全透明,这样的折中的解决了这个问题。

    分享我的代码 我打开的是四波段。

               string imgFileName;
                string LayerName;
                string imgFilePath;

                imgFilePath = "C:\\IR1";
                //shpFileName = "y0972920378.shp";
                imgFileName = "2009年12月30日4时0分FY2E红外图像.img";
                LayerName = "fengyun";


                IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
                IWorkspace workspace;
                workspace = workspaceFactory.OpenFromFile(imgFilePath, 0); //inPath栅格数据存储路径

                IRasterWorkspace rastWork = (IRasterWorkspace)workspace;
                IRasterDataset rasterDatst;
                rasterDatst = rastWork.OpenRasterDataset(imgFileName);//inName栅格文件名

          
                IGroupLayer pGroupLayer = new GroupLayerClass();
                IRasterLayer prasterLayer = new RasterLayerClass();
                int pBandCount;
                IRasterBandCollection pRasterBands;
                pRasterBands = (IRasterBandCollection)rasterDatst;

                pBandCount = pRasterBands.Count;
                if (pBandCount <= 3)
                {
                    prasterLayer.CreateFromDataset(rasterDatst);
                    prasterLayer.Name = LayerName;

                    MapMain.AddLayer(prasterLayer,0);
                    MapMain.Refresh();
                    TOCControl.Refresh();
                }
                else
                {
                    //添加 前三个波段
                    prasterLayer.CreateFromDataset(rasterDatst);
                    prasterLayer.Name = LayerName;

                    MapMain.AddLayer(prasterLayer, 0);
                    MapMain.Refresh();
                    TOCControl.Refresh();

                    IRasterBand pBand;
                    IRaster pRaster = new RasterClass();
                    //IRasterBandCollection pRasterbandColln;
                    IRasterLayer pRasterLayer1 = new RasterLayerClass();
                    IRasterDataset MyDs;
                    string pBandname;
                    //添加后面的波段
                    for (int i = 3; i < pBandCount; i++)
                    {
                        pBand = pRasterBands.Item(i);
                        IRasterBandCollection pRasterbandColln = (IRasterBandCollection)pRaster;
                        pRasterbandColln.Clear();
                        pRasterbandColln.AppendBand(pBand);

                        pRasterLayer1.CreateFromRaster((IRaster)pRasterbandColln);
                        pBandname = pBand.Bandname;
                        pBandname = LayerName + "-" + pBandname;
                        pRasterLayer1.Name = pBandname;

                        MapMain.AddLayer(pRasterLayer1, 0);
                        MapMain.Refresh();
                        TOCControl.Refresh();
                    }

                    //透明度设置
                    ILayerEffects pLayerEffects;
                    pLayerEffects = (ILayerEffects)MapMain.get_Layer(0);
                    if (pLayerEffects.SupportsTransparency == true)
                    {
                        pLayerEffects.Transparency = 100;
                    }

                    //透明度设置
                    pLayerEffects = (ILayerEffects)MapMain.get_Layer(1);
                    if (pLayerEffects.SupportsTransparency == true)
                    {
                        pLayerEffects.Transparency = 35;
                    }
                    MapMain.Refresh();
                    TOCControl.Refresh();

                }

               此方法有问题,在AE9.3中测试,都是获得的第一个波段。

  • 相关阅读:
    java.net.BindException: Cannot assign requested address: bind
    Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'name': was expecting ('true', 'false' or 'null')
    springMVC上传错误StandardMultipartHttpServletRequest
    常用软件
    虚拟机修改静态ip
    linux下脚本做成服务
    Unable to resolve persistence unit root URL
    MyBatis对不同数据库的主键生成策略
    MyBatis定义复合主键
    MongoDB安装,启动,注册为windows系统服务
  • 原文地址:https://www.cnblogs.com/yuxuetaoxp/p/1733222.html
Copyright © 2011-2022 走看看