Exemplo n.º 1
0
        //创建颜色带
        private IColorRamp CreateAlgorithmicColorRamp(int count)
        {
            //创建一个新AlgorithmicColorRampClass对象
            IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();
            IRgbColor             fromColor    = new RgbColorClass();
            IRgbColor             toColor      = new RgbColorClass();

            //创建起始颜色对象
            fromColor.Red   = 255;
            fromColor.Green = 0;
            fromColor.Blue  = 0;
            //创建终止颜色对象
            toColor.Red   = 0;
            toColor.Green = 0;
            toColor.Blue  = 255;
            //设置AlgorithmicColorRampClass的起止颜色属性
            algColorRamp.ToColor   = fromColor;
            algColorRamp.FromColor = toColor;
            //设置梯度类型
            algColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            //设置颜色带颜色数量
            algColorRamp.Size = count;
            //创建颜色带
            bool bture = true;

            algColorRamp.CreateRamp(out bture);
            return(algColorRamp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据单波段拉伸渲染
        /// </summary>
        /// <param name="rasterDataset">栅格数据集</param>
        /// <param name="graypos">第几波段</param>
        /// <param name="stretchType">拉伸方式</param>
        /// <param name="pFromColor">fromColor</param>
        /// <param name="pToColor">toColor</param>
        /// <returns></returns>
        public static IRasterRenderer StretchRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset rasterDataset, int graypos,
                                                      esriRasterStretchTypesEnum stretchType, IRgbColor pFromColor, IRgbColor pToColor)
        {
            try
            {
                //Create the color ramp.
                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();
                colorRamp.Size      = 255;
                colorRamp.FromColor = pFromColor;
                colorRamp.ToColor   = pToColor;
                bool createColorRamp;
                colorRamp.CreateRamp(out createColorRamp);
                //Create a stretch renderer.
                IRasterStretchColorRampRenderer stretchRenderer = new
                                                                  RasterStretchColorRampRendererClass();

                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;
                //Set the renderer properties.
                IRaster raster = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster = raster;
                rasterRenderer.Update();
                stretchRenderer.BandIndex = graypos;
                stretchRenderer.ColorRamp = colorRamp;
                //Set the stretch type.
                IRasterStretch pRasterStretch = (IRasterStretch)rasterRenderer;
                pRasterStretch.StretchType             = stretchType;
                pRasterStretch.StandardDeviationsParam = 2;
                return(rasterRenderer);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        //创建颜色带
        private IColorRamp CreateAlgorithmicColorRamp(int count)
        {
            IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();
            IRgbColor             fromColor    = new RgbColorClass();
            IRgbColor             toColor      = new RgbColorClass();

            fromColor.Red   = 255;
            fromColor.Green = 255;
            fromColor.Blue  = 255;

            toColor.Red   = 255;
            toColor.Green = 0;
            toColor.Blue  = 0;

            algColorRamp.ToColor = toColor;

            algColorRamp.FromColor = fromColor;


            algColorRamp.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;

            algColorRamp.Size = count;

            bool bture = true;

            algColorRamp.CreateRamp(out bture);
            return(algColorRamp);
        }
Exemplo n.º 4
0
        //渲染建设用地适宜级栅格图
        public void Render()
        {
            if (this.RasterLayerClass != null)
            {
                RgbColorClass pFromColor = new RgbColorClass();
                pFromColor.Red   = 255; //红色
                pFromColor.Green = 0;
                pFromColor.Blue  = 0;

                RgbColorClass pToColor = new RgbColorClass();
                pToColor.Red   = 0;
                pToColor.Green = 255; //绿色
                pToColor.Blue  = 0;

                bool ok = false;

                AlgorithmicColorRampClass acrc = new AlgorithmicColorRampClass();
                acrc.Size      = 255;
                acrc.FromColor = pFromColor as IColor;
                acrc.ToColor   = pToColor as IColor;
                acrc.CreateRamp(out ok);

                RasterStretchColorRampRendererClass scr = new RasterStretchColorRampRendererClass();
                scr.Raster = this.RasterLayerClass.Raster;   //显示图例
                scr.Update();                                //显示图例
                scr.BandIndex = 0;
                scr.ColorRamp = acrc as IColorRamp;
                scr.Update();                                //显示图例

                this.RasterLayerClass.Renderer = scr;
            }
        }
Exemplo n.º 5
0
        public static IRasterRenderer ClassifyRenderer(IRasterLayer raslyr,IRgbColor start_clr,IRgbColor end_clr,int count)
        {
            IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRendererClass();
            IRasterRenderer rasterRenderer = pRClassRend as IRasterRenderer;

            IRaster pRaster = raslyr.Raster;
            IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;
            IRasterBand pRBand = pRBandCol.Item(0);
            if (pRBand.Histogram == null)
            {
                pRBand.ComputeStatsAndHist();
            }
            rasterRenderer.Raster = pRaster;
            pRClassRend.ClassCount = count;
            rasterRenderer.Update();

            IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();
            colorRamp.Size = count;
            colorRamp.FromColor = start_clr;
            colorRamp.ToColor = end_clr;
            bool createColorRamp;
            colorRamp.CreateRamp(out createColorRamp);

            IFillSymbol fillSymbol = new SimpleFillSymbolClass();
            for (int i = 0; i < pRClassRend.ClassCount; i++)
            {
                fillSymbol.Color = colorRamp.get_Color(i);
                pRClassRend.set_Symbol(i, fillSymbol as ISymbol);
                pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00"));
            }
            return rasterRenderer;
        }
Exemplo n.º 6
0
        private void button4_Click(object sender, EventArgs e)
        {
            int    selectedFieldIndex            = m_pTarFeatureLayer.FeatureClass.Fields.FindField(comboBox1.SelectedItem.ToString());
            IField selectedField                 = m_pTarFeatureLayer.FeatureClass.Fields.get_Field(selectedFieldIndex);
            IUniqueValueRenderer unqValueRenderr = new UniqueValueRendererClass();

            #region UniqueValueRenderer需要定义字段数,字段名,并最后添加字段中每一种值对应的渲染方式(AddValue)
            unqValueRenderr.FieldCount = 1;
            unqValueRenderr.set_Field(0, selectedField.Name);//0是干什么的?
            #endregion
            IAlgorithmicColorRamp acr = new AlgorithmicColorRampClass();
            acr.FromColor = m_pFillColor;
            acr.ToColor   = m_pOutlineColor;
            acr.Size      = m_pTarFeatureLayer.FeatureClass.FeatureCount(null);
            bool isOK;
            acr.CreateRamp(out isOK);
            #region 很迷,不知道为什么直接acr.colors.next遍历不了colorramp
            IEnumColors enumColor = acr.Colors;
            IColor      curColor  = enumColor.Next();
            #endregion
            #region 开始遍历图层获取所有feature
            for (int i = 0; i < m_pTarFeatureLayer.FeatureClass.FeatureCount(null); i++)
            {
                IFeature curFeature = m_pTarFeatureLayer.FeatureClass.GetFeature(i);
                switch (m_pTarFeatureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
                    sfs.Color = curColor;
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sfs as ISymbol);
                    break;
                }

                case esriGeometryType.esriGeometryPoint:
                {
                    ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass
                    {
                        Color = curColor
                    };
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sms as ISymbol);
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    ISimpleLineSymbol sls = new SimpleLineSymbolClass();
                    sls.Color = curColor;
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sls as ISymbol);
                    break;
                }
                }
                curColor = enumColor.Next();
            }
            m_pTarGeoFeatureLayer.Renderer = unqValueRenderr as IFeatureRenderer;
            frmMainOper(OperationType.RefreshMapCtrl);
            frmMainOper(OperationType.UpdateTOCCtrl);
            #endregion
        }
Exemplo n.º 7
0
        public static IAlgorithmicColorRamp CreateAlgorithmicColorRamp(IColor pStartColor, IColor pEndColor, esriColorRampAlgorithm eColorAlgorithm = esriColorRampAlgorithm.esriHSVAlgorithm, int iSize = 500)
        {
            IAlgorithmicColorRamp pAlgorithmicColorRamp = new AlgorithmicColorRampClass();

            pAlgorithmicColorRamp.FromColor = pStartColor;
            pAlgorithmicColorRamp.ToColor   = pEndColor;
            pAlgorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicColorRamp.Size      = iSize;
            bool bOK = true;

            pAlgorithmicColorRamp.CreateRamp(out bOK);
            return(pAlgorithmicColorRamp);
        }
Exemplo n.º 8
0
        private IColorRamp getRamp()
        {
            IAlgorithmicColorRamp ramp = new AlgorithmicColorRampClass();

            ramp.FromColor = ColorToIColor(colorPickEdit1.Color);
            ramp.ToColor   = ColorToIColor(colorPickEdit2.Color);
            ramp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            ramp.Size      = Convert.ToInt16(spinEdit1.Text);
            bool b = true;

            ramp.CreateRamp(out b);
            return(ramp);
        }
Exemplo n.º 9
0
        //AlgorithmicColorRamp是通过起止颜色来确定多个在这两个颜色之间的色带
        private IEnumColors createAlgorithmicColorRamp(IColor fromColor, IColor toColor, int count)
        {
            IAlgorithmicColorRamp pRampColor;

            pRampColor           = new AlgorithmicColorRampClass();
            pRampColor.FromColor = fromColor;
            pRampColor.ToColor   = toColor;
            pRampColor.Size      = count;
            bool ok;

            pRampColor.CreateRamp(out ok);
            return(pRampColor.Colors);
        }
Exemplo n.º 10
0
        public static IEnumColors CreateColors(IRgbColor fromColor, IRgbColor toColor, int size)
        {
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass()
            {
                FromColor = fromColor,
                ToColor   = toColor,
                Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm,
                Size      = size
            };
            bool bOk = true;

            pColorRamp.CreateRamp(out bOk);
            return(pColorRamp.Colors);
        }
Exemplo n.º 11
0
        // 获取渐变颜色集
        public IColorRamp GetColorRamp(IRgbColor fromColor, IRgbColor toColor, int size)
        {
            IColorRamp pColorRamp = new AlgorithmicColorRampClass()
            {
                FromColor = fromColor,
                ToColor   = toColor,
                Size      = size,
                Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm
            };
            bool bOk = true;

            pColorRamp.CreateRamp(out bOk);
            return(pColorRamp);
        }
Exemplo n.º 12
0
        // 创建渐变色带
        public static IAlgorithmicColorRamp CreateColorRamp(IRgbColor fromColor, IRgbColor toColor, int size = 10)
        {
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass()
            {
                FromColor = fromColor, ToColor = toColor,               // 起止颜色
                Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm, // 梯度类型
                Size      = size                                        // 色带颜色数量
            };
            // 创建色带
            bool bture = true;

            pColorRamp.CreateRamp(out bture);
            return(pColorRamp);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 根据容积率大小进行梯度颜色显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            //梯度颜色算法
            IAlgorithmicColorRamp pAlgoColorRamp = new AlgorithmicColorRampClass();

            pAlgoColorRamp.Size = MyArray.Length;

            IRgbColor pFromColor = new RgbColorClass(), pToColor = new RgbColorClass();

            pFromColor.Red   = 255;
            pFromColor.Green = 255;
            pFromColor.Blue  = 255;

            pToColor.Red   = 0;
            pToColor.Green = 255;
            pToColor.Blue  = 255;

            pAlgoColorRamp.FromColor = pFromColor;
            pAlgoColorRamp.ToColor   = pToColor;

            bool ok = true;

            pAlgoColorRamp.CreateRamp(out ok);


            IClassBreaksRenderer pRender = new ClassBreaksRendererClass();

            pRender.BreakCount = MyArray.Length;
            pRender.Field      = "Plot_Ratio";

            ISimpleFillSymbol pSym;

            System.Array.Sort(MyArray);

            for (int i = 0; i < MyArray.Length; i++)
            {
                pRender.set_Break(i, (double)MyArray.GetValue(i));
                pSym       = new SimpleFillSymbolClass();
                pSym.Color = pAlgoColorRamp.get_Color(i);
                pRender.set_Symbol(i, (ISymbol)pSym);
            }

            IGeoFeatureLayer pGeoLyr = (IGeoFeatureLayer)Form1.mainForm.axMapControl1.get_Layer(1);//确保先加入地块图层

            pGeoLyr.Renderer = (IFeatureRenderer)pRender;

            Form1.mainForm.axMapControl1.Refresh();
            Form1.mainForm.axTOCControl1.Update();
        }
Exemplo n.º 14
0
        /// <summary>
        /// 拉伸渲染模式(貌似)
        /// </summary>
        /// <param name="rasterDataset"></param>
        /// <returns></returns>
        private static IRasterRenderer StretchRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset rasterDataset, int graypos, int i)
        {
            try
            {
                //Define the from and to colors for the color ramp.
                IRgbColor fromColor = new RgbColorClass();
                fromColor.Red   = 255;
                fromColor.Green = 0;
                fromColor.Blue  = 0;
                IColor toColor = new RgbColorClass();
                //此处应该是写错了
                fromColor.Red   = 0;
                fromColor.Green = 255;
                fromColor.Blue  = 0;
                //Create the color ramp.
                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();
                colorRamp.Size      = 255;
                colorRamp.FromColor = fromColor;
                colorRamp.ToColor   = toColor;
                bool createColorRamp;
                colorRamp.CreateRamp(out createColorRamp);
                //Create a stretch renderer.
                IRasterStretchColorRampRenderer stretchRenderer = new
                                                                  RasterStretchColorRampRendererClass();

                //设置显示对比度和亮度
                //((IRasterDisplayProps)stretchRenderer).BrightnessValue = -90;
                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;


                //Set the renderer properties.
                IRaster raster = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster = raster;
                rasterRenderer.Update();
                stretchRenderer.BandIndex = graypos;
                //stretchRenderer.ColorRamp = colorRamp;
                //Set the stretch type.
                IRasterStretch stretchType = (IRasterStretch)rasterRenderer;
                stretchType.StretchType             = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                stretchType.StandardDeviationsParam = 2;
                return(rasterRenderer);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取渐变色带
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public static IAlgorithmicColorRamp GetDefaultGradualColor(int size)
        {
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();

            pColorRamp.FromColor = AeColor.GetRgbColor(0, 255, 0);
            pColorRamp.ToColor   = AeColor.GetRgbColor(0, 0, 255);
            if (size <= 1)
            {
                size = 2;
            }

            pColorRamp.Size = size; //渐变颜色带范围
            bool ok;

            pColorRamp.CreateRamp(out ok);
            return(pColorRamp);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 根据单波段灰度渲染
        /// </summary>
        /// <param name="rasterDataset">栅格数据集</param>
        /// <param name="graypos">第几波段</param>
        /// <returns></returns>
        public static IRasterRenderer StretchRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset rasterDataset, int graypos)
        {
            try
            {
                //Define the from and to colors for the color ramp.
                IRgbColor fromColor = new RgbColorClass();
                fromColor.Red = 255;
                fromColor.Green = 0;
                fromColor.Blue = 0;
                IColor toColor = new RgbColorClass();
                fromColor.Red = 0;
                fromColor.Green = 255;
                fromColor.Blue = 0;
                //Create the color ramp.
                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();
                colorRamp.Size = 255;
                colorRamp.FromColor = fromColor;
                colorRamp.ToColor = toColor;
                bool createColorRamp;
                colorRamp.CreateRamp(out createColorRamp);
                //Create a stretch renderer.
                IRasterStretchColorRampRenderer stretchRenderer = new
                RasterStretchColorRampRendererClass();

                //设置显示对比度和亮度
                //((IRasterDisplayProps)stretchRenderer).BrightnessValue = -90;
                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;

                //Set the renderer properties.
                IRaster raster = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster = raster;
                rasterRenderer.Update();
                stretchRenderer.BandIndex = graypos;
                //stretchRenderer.ColorRamp = colorRamp;
                //Set the stretch type.
                IRasterStretch stretchType = (IRasterStretch)rasterRenderer;
                stretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                stretchType.StandardDeviationsParam = 2;
                return rasterRenderer;
            }
            catch
            {
                return null;
            }
        }
Exemplo n.º 17
0
        public static IRasterRenderer ClassifyRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset pRasterDataset)
        {
            try
            {
                //create the classify render:创建渲染器
                IRasterClassifyColorRampRenderer pClassifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer pRasterRenderer = (IRasterRenderer)pClassifyRenderer;
                IRaster         pRaster         = pRasterDataset.CreateDefaultRaster();
                pRasterRenderer.Raster       = pRaster;
                pClassifyRenderer.ClassCount = 10;
                pRasterRenderer.Update();

                //创建颜色
                IRgbColor pFromColor = new RgbColorClass();
                pFromColor.Red   = 255;
                pFromColor.Green = 0;
                pFromColor.Blue  = 0;
                IRgbColor pToColor = new RgbColorClass();
                pToColor.Red   = 0;
                pToColor.Green = 255;
                pToColor.Blue  = 255;

                //set the color ramp for the symbology:生成色带
                IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
                pRamp.Size      = 10;
                pRamp.FromColor = pFromColor;
                pRamp.ToColor   = pToColor;
                bool pBoolColorRamp;
                pRamp.CreateRamp(out pBoolColorRamp);
                //create the symbol for the classes.:创建符号
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                for (int i = 0; i < pClassifyRenderer.ClassCount; i++)
                {
                    pFillSymbol.Color = pRamp.get_Color(i);
                    pClassifyRenderer.set_Symbol(i, (ISymbol)pFillSymbol);
                    pClassifyRenderer.set_Label(i, Convert.ToString(i));
                }
                return(pRasterRenderer);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemplo n.º 18
0
 protected override void OnClick()
 {
     try
     {
         IAlgorithmicColorRamp colorRampe = new AlgorithmicColorRampClass();
         colorRampe.FromColor = (new RgbColorClass() { Red = 255, Green = 0, Blue = 255 }) as IColor;
         colorRampe.ToColor = (new RgbColorClass() { Red = 255, Green = 0, Blue = 0 }) as IColor;
         colorRampe.Size = 256;
         colorRampe.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
         bool ok = false;
         colorRampe.CreateRamp(out ok);
         MessageBox.Show(colorRampe.Color[255].RGB.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// 根据起点颜色、终点颜色和级别数目,产生色带
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="gradecount"></param>
        /// <returns></returns>
        private static IEnumColors ProduceEnumColors(Color start, Color end, int gradecount)
        {
            //创建一个新AlgorithmicColorRampClass对象
            IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();

            algColorRamp.ToColor   = ConvertColorToIColor(end);//从.net的颜色转换
            algColorRamp.FromColor = ConvertColorToIColor(start);
            //设置梯度类型
            algColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            //设置颜色带颜色数量
            algColorRamp.Size = gradecount;
            //创建颜色带
            bool bture = true;

            algColorRamp.CreateRamp(out bture);
            //使用IEnumColors获取颜色带
            return(algColorRamp.Colors);
        }
Exemplo n.º 20
0
        public static void funColorForRaster_Classify(IRasterLayer pRasterLayer, int ClassNum)
        {
            IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRendererClass();
            IRasterRenderer       pRRend    = pRClassRend as IRasterRenderer;
            IRaster               pRaster   = pRasterLayer.Raster;
            IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;
            IRasterBand           pRBand    = pRBandCol.Item(0);

            if (pRBand.Histogram == null)
            {
                pRBand.ComputeStatsAndHist();
            }
            pRRend.Raster          = pRaster;
            pRClassRend.ClassCount = ClassNum;
            pRRend.Update();
            IRgbColor pFromColor = new RgbColorClass();

            pFromColor.Red   = 0;//绿
            pFromColor.Green = 255;
            pFromColor.Blue  = 0;
            IRgbColor pToColor = new RgbColorClass();

            pToColor.Red   = 255;//红
            pToColor.Green = 0;
            pToColor.Blue  = 0;
            IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();

            colorRamp.Size      = ClassNum;
            colorRamp.FromColor = pFromColor;
            colorRamp.ToColor   = pToColor;
            bool createColorRamp;

            colorRamp.CreateRamp(out createColorRamp);
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();

            for (int i = 0; i < pRClassRend.ClassCount; i++)
            {
                fillSymbol.Color = colorRamp.get_Color(i);
                pRClassRend.set_Symbol(i, fillSymbol as ISymbol);
                pRClassRend.set_Label(i, (i + 1).ToString());
            }
            pRasterLayer.Renderer = pRRend;
            MainFrom.m_mapControl.AddLayer(pRasterLayer);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a renderer for output rasters.
        /// </summary>
        /// <param name="pRL"></param>
        /// <param name="pColor1"></param>
        /// <param name="pColor2"></param>
        private void CreateRasterStretchRenderer(IRasterLayer pRL, IRgbColor pColor1, IRgbColor pColor2)
        {
            try
            {
                IRaster pRaster = pRL.Raster;
                IRasterStretchColorRampRenderer pStretchRen = new RasterStretchColorRampRendererClass();
                IRasterRenderer       pRasRen;
                IAlgorithmicColorRamp pRamp    = new AlgorithmicColorRampClass();
                IStyleGallery         pGallery = new StyleGalleryClass();

                bool bCreate;

                //create renderer
                pRasRen        = (IRasterRenderer)pStretchRen;
                pRasRen.Raster = pRaster;
                pRasRen.Update();

                //create color ramp
                pRamp.Size      = 255;
                pRamp.FromColor = pColor1;
                pRamp.ToColor   = pColor2;
                pRamp.CreateRamp(out bCreate);

                //apply the color ramp
                pStretchRen.BandIndex = 0;
                pStretchRen.ColorRamp = pRamp;
                IRasterStretch pRasStretch = (IRasterStretch)pStretchRen;
                pRasStretch.Background = true;
                double dValue = 0;
                pRasStretch.set_BackgroundValues(ref dValue);

                pRasRen.Update();
                pRL.Renderer = (IRasterRenderer)pStretchRen;
                ArcMap.Document.ActiveView.Refresh();
                ArcMap.Document.UpdateContents();
            }

            catch (Exception ex)
            {
                clsStatic.ShowErrorMessage(ex.ToString());
            }
        }
Exemplo n.º 22
0
        public static IRasterRenderer StretchRender(IRasterDataset pRasterDataset)
        {
            try
            {
                //Define the from and to colors for the color ramp
                IRgbColor pFromColor = new RgbColorClass();
                pFromColor.Red   = 255;
                pFromColor.Green = 0;
                pFromColor.Blue  = 0;
                IRgbColor pToColor = new RgbColorClass();
                pToColor.Red   = 0;
                pToColor.Green = 255;
                pToColor.Blue  = 0;

                IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
                pRamp.Size      = 10;
                pRamp.FromColor = pFromColor;
                pRamp.ToColor   = pToColor;
                bool createColorRamp;
                pRamp.CreateRamp(out createColorRamp);
                //create a stretch renderer
                IRasterStretchColorRampRenderer pStrechRenderer = new RasterStretchColorRampRendererClass();
                IRasterRenderer pRasterRenderer = (IRasterRenderer)pStrechRenderer;
                //set the renderer properties
                IRaster pRaster = pRasterDataset.CreateDefaultRaster();
                pRasterRenderer.Raster = pRaster;
                pRasterRenderer.Update();
                //
                pStrechRenderer.BandIndex = 0;
                pStrechRenderer.ColorRamp = pRamp;
                IRasterStretch pStretchType = (IRasterStretch)pRasterRenderer;
                pStretchType.StretchType             = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                pStretchType.StandardDeviationsParam = 2;
                return(pRasterRenderer);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 打开adf文件格式栅格数据
        /// </summary>
        /// <param name="rasterPath"></param>
        /// <param name="fileName"></param>
        public static void OpenRasterLayer(string rasterPath, string fileName)
        {
            IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
            IWorkspace        SWorkspace       = workspaceFactory.OpenFromFile(rasterPath, 0);
            IRasterWorkspace  rasterWorkspace  = SWorkspace as IRasterWorkspace;
            IRasterDataset    pRasterDataset   = (IRasterDataset)rasterWorkspace.OpenRasterDataset(fileName);
            IRasterLayer      pRasterLayer     = new RasterLayerClass();

            pRasterLayer.CreateFromDataset(pRasterDataset);
            IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass()
            {
                FromColor = new RgbColorClass()
                {
                    Red = 197, Green = 68, Blue = 56
                },
                ToColor = new RgbColorClass()
                {
                    Red = 80, Green = 110, Blue = 207
                },
                Size = 100
            };//Red = 80, Green = 110, Blue = 207
            IMultiPartColorRamp multiPartColorRamp = new MultiPartColorRampClass();

            multiPartColorRamp.set_Ramp(0, colorRamp);
            bool outCreate = false;

            colorRamp.CreateRamp(out outCreate);
            //设置渲染参数
            IRasterStretchColorRampRenderer rasterStretchColorRampRenderer = new RasterStretchColorRampRendererClass();
            IRasterRenderer rasterRenderer = rasterStretchColorRampRenderer as IRasterRenderer;

            rasterRenderer.Raster = pRasterLayer.Raster;
            rasterRenderer.Update();
            rasterStretchColorRampRenderer.BandIndex = 0;
            rasterStretchColorRampRenderer.ColorRamp = multiPartColorRamp as IColorRamp;
            rasterRenderer.Update();
            pRasterLayer.Renderer = rasterRenderer;
            MainFrom.m_mapControl.AddLayer(pRasterLayer);
        }
        /// <summary>
        /// 依据色带渲染栅格
        /// </summary>
        /// <param name="pRasterLayer"></param>
        public void SetStretchColorRampRender(IRasterLayer pRasterLayer)
        {
            try
            {
                IRasterStretchColorRampRenderer pRampRenderer = new RasterStretchColorRampRendererClass();
                IRasterRenderer pRasterRenderer = pRampRenderer as IRasterRenderer;
                pRasterRenderer.Raster = pRasterLayer.Raster;
                pRasterRenderer.Update();
                //创建起始颜色
                IColor fromColor = GetColor(40, 146, 179);
                IColor toColor   = GetColor(255, 255, 100);
                //创建起止色带
                IAlgorithmicColorRamp pAlgorithmicColorRamp = new AlgorithmicColorRampClass();
                pAlgorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                pAlgorithmicColorRamp.Size      = 255;
                pAlgorithmicColorRamp.FromColor = fromColor;
                pAlgorithmicColorRamp.ToColor   = toColor;
                bool btrue = true;
                pAlgorithmicColorRamp.CreateRamp(out btrue);
                //选择拉伸颜色符号的波段
                pRampRenderer.BandIndex = 0;
                pRampRenderer.ColorRamp = pAlgorithmicColorRamp as IColorRamp;
                pRasterRenderer.Update();
                pRasterLayer.Renderer = pRasterRenderer;

                this._pMap.AddLayer(pRasterLayer);
                IActiveView pActiveView = _pMap as IActiveView;
                if (pActiveView != null)
                {
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    pActiveView.Extent = pActiveView.FullExtent;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 25
0
        /// <summary>
        ///  创建色带
        /// </summary>
        /// <returns>IColorRamp 色带</returns>
        public static IColorRamp CreateAlgorithmicColorRamp()
        {
            // 创建一个新的AlgorithmicColorRampClass对象
            IAlgorithmicColorRamp algorithmicColorRamp = new AlgorithmicColorRampClass();
            // 创建起始终止颜色
            IRgbColor fromColor = GetRgbColor(255, 0, 0);
            IRgbColor toColor   = GetRgbColor(0, 255, 0);

            algorithmicColorRamp.FromColor = fromColor;
            algorithmicColorRamp.ToColor   = toColor;

            // 设置梯度类型
            algorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            // 设置颜色色带数量
            algorithmicColorRamp.Size = 10;

            // 创建颜色带
            bool bTrue = true;

            algorithmicColorRamp.CreateRamp(out bTrue);

            return(algorithmicColorRamp);
        }
Exemplo n.º 26
0
 protected override void OnClick()
 {
     try
     {
         IAlgorithmicColorRamp colorRampe = new AlgorithmicColorRampClass();
         colorRampe.FromColor = (new RgbColorClass()
         {
             Red = 255, Green = 0, Blue = 255
         }) as IColor;
         colorRampe.ToColor   = (new RgbColorClass()
         {
             Red = 255, Green = 0, Blue = 0
         }) as IColor;
         colorRampe.Size      = 256;
         colorRampe.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
         bool ok = false;
         colorRampe.CreateRamp(out ok);
         MessageBox.Show(colorRampe.Color[255].RGB.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Class Break Render
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="breakCount"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091114</date>
        public static void ClassBreakRender(ILayer currentLayer, int breakCount, string fieldName, ref double[] Classes, ref int[] Colors, bool reverse)
        {
            //Get All Value
            object          dataFrequency   = null;
            object          dataValues      = null;
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pHistogram      = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = fieldName;
            pTableHistogram.Table = (currentLayer as IGeoFeatureLayer).DisplayFeatureClass as ITable;
            pHistogram.GetHistogram(out dataValues, out dataFrequency);

            //Class
            IClassifyGEN pClassify = new EqualIntervalClass();

            pClassify.Classify(dataValues, dataFrequency, ref breakCount);

            //Set Class Breaks
            Classes = (double[])pClassify.ClassBreaks;
            int ClassesCount = Classes.GetUpperBound(0);
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();

            pClassBreaksRenderer.Field = fieldName;

            //Set From to Color
            IHsvColor pFromColor = new HsvColorClass();

            pFromColor.Hue        = reverse ? 105 : 353;
            pFromColor.Saturation = reverse ? 46 : 56;
            pFromColor.Value      = reverse ? 76 : 92;
            IHsvColor pToColor = new HsvColorClass();

            pToColor.Hue        = reverse ? 353 : 105;
            pToColor.Saturation = reverse ? 56 : 46;
            pToColor.Value      = reverse ? 92 : 76;

            //Get Color
            IAlgorithmicColorRamp pAlgorithmicCR = new AlgorithmicColorRampClass();

            pAlgorithmicCR.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicCR.FromColor = pFromColor;
            pAlgorithmicCR.ToColor   = pToColor;
            pAlgorithmicCR.Size      = ClassesCount;
            bool ok = false;

            pAlgorithmicCR.CreateRamp(out ok);
            IEnumColors pEnumColors = pAlgorithmicCR.Colors;

            //Set Break Count
            pClassBreaksRenderer.BreakCount           = ClassesCount;
            pClassBreaksRenderer.SortClassesAscending = true;

            //Set Break Interval
            for (int lbreakIndex = 0; lbreakIndex <= ClassesCount - 1; lbreakIndex++)
            {
                IColor pColor = pEnumColors.Next();
                Colors[lbreakIndex] = pColor.RGB;
                ISimpleFillSymbol pSimpleFillS = new SimpleFillSymbolClass();
                pSimpleFillS.Color = pColor;
                pSimpleFillS.Style = esriSimpleFillStyle.esriSFSSolid;
                pClassBreaksRenderer.set_Symbol(lbreakIndex, (ISymbol)pSimpleFillS);
                pClassBreaksRenderer.set_Break(lbreakIndex, Classes[lbreakIndex + 1]);
            }

            //Set Render
            (currentLayer as IGeoFeatureLayer).Renderer = pClassBreaksRenderer as IFeatureRenderer;
        }
Exemplo n.º 28
0
        private void polygonClassificationDye(ILayer pLayer)
        {
            IGeoFeatureLayer pGeoFeatureLayer;
            ITable           pTable;
            IClassifyGEN     pClassify;
            ITableHistogram  pTableHistogram;
            IBasicHistogram  pHistogram;
            object           dataFrequency;

            object dataValues;

            double[]             Classes;
            int                  ClassesCount;
            IClassBreaksRenderer pClassBreakRenderer;
            IHsvColor            pFromColor;
            IHsvColor            pToColor;

            IAlgorithmicColorRamp pAIgorithmicCR;

            IEnumColors pEnumColors;

            bool ok;

            IColor            pColor;
            ISimpleFillSymbol pSimpleFillS;
            int    IbreakIndex;
            string strPopFiled = cbField1.Text;
            int    numDesiredClasses;

            try
            {
                numDesiredClasses = int.Parse(textBox1.Text.ToString());
            }
            catch
            {
                MessageBox.Show("请输入分级个数");
                return;
            }

            IMap pMap = axMapControl1.Map;

            pMap.ReferenceScale = 0;
            pGeoFeatureLayer    = pLayer as IGeoFeatureLayer;
            //从pTable的id字段中得到信息给dataValues和dataFrequency两个数组
            pTable                = (ITable)pGeoFeatureLayer.FeatureClass;
            pTableHistogram       = new BasicTableHistogramClass();
            pHistogram            = (IBasicHistogram)pTableHistogram;
            pTableHistogram.Field = strPopFiled;
            pTableHistogram.Table = pTable;
            pHistogram.GetHistogram(out dataValues, out dataFrequency);
            //下面是分级方法,用于根据获取的值计算出符号要求的数据
            pClassify = new EqualIntervalClass();
            try
            {
                pClassify.Classify(dataValues, dataFrequency, ref numDesiredClasses);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //返回一个数组
            Classes                   = (double[])pClassify.ClassBreaks;
            ClassesCount              = Classes.GetUpperBound(0);
            pClassBreakRenderer       = new ClassBreaksRendererClass();
            pClassBreakRenderer.Field = strPopFiled;
            //设置着色对象的分级数目
            pClassBreakRenderer.BreakCount           = ClassesCount;
            pClassBreakRenderer.SortClassesAscending = true;
            //产生分级着色需要的颜色带对象的起止颜色对象
            pFromColor            = new HsvColorClass();
            pFromColor.Hue        = 60;
            pFromColor.Saturation = 100;
            pFromColor.Value      = 96;
            pToColor            = new HsvColorClass();
            pToColor.Hue        = 0;
            pToColor.Saturation = 100;
            pToColor.Value      = 96;
            //产生颜色带对象
            pAIgorithmicCR           = new AlgorithmicColorRampClass();
            pAIgorithmicCR.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAIgorithmicCR.FromColor = pFromColor;
            pAIgorithmicCR.ToColor   = pToColor;
            pAIgorithmicCR.Size      = ClassesCount;
            pAIgorithmicCR.CreateRamp(out ok);
            //获得颜色
            pEnumColors = pAIgorithmicCR.Colors;
            //分类着色对象中的symbol和break的下标是从0开始
            for (IbreakIndex = 0; IbreakIndex <= ClassesCount - 1; IbreakIndex++)
            {
                pColor             = pEnumColors.Next();
                pSimpleFillS       = new SimpleFillSymbolClass();
                pSimpleFillS.Color = pColor;
                pSimpleFillS.Style = esriSimpleFillStyle.esriSFSSolid;
                //这里是构造函数不同颜色着色的方法
                pClassBreakRenderer.set_Symbol(IbreakIndex, (ISymbol)pSimpleFillS);
                //着色对象的断点
                pClassBreakRenderer.set_Break(IbreakIndex, Classes[IbreakIndex + 1]);
            }
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pClassBreakRenderer;
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Exemplo n.º 29
0
        private void btnClassBreakRender_Click(object sender, EventArgs e)
        {
            //先用一个ITableHistogram对象从一个要素类获取某一字段的所有值及频率,即dataValues和dataFrequency,这两个数组是分组的基本数据
            //取得两个数组后,系统用IClassGEN对象对它们进行分级,得到classes及classCount,前者是分级临界点值的数组,后者为分级数目
            //根据得到的分级数目和颜色带对象,可以分别设置ClassBreakRender对象的不同符号,产生不同的效果
            IGeoFeatureLayer pGeoFeatLyr;
            ITable pTable;

            object dataValues;
            object dataFrequency;
            string strOutput;

            pGeoFeatLyr = this.mainMapControl.get_Layer(0) as IGeoFeatureLayer;
            pTable = pGeoFeatLyr as ITable;
            //以下代码用TableHistogram和BasicHistogram统计出Table某一字段的值和值的频率
            ITableHistogram pTableHistogram;
            pTableHistogram = new BasicTableHistogramClass();
            pTableHistogram.Table = pTable;//需传入一个ITable
            pTableHistogram.Field = "GDP_1999(";//统计的字段
            IBasicHistogram pBasicHistogram;
            pBasicHistogram = pTableHistogram as IBasicHistogram;
            pBasicHistogram.GetHistogram(out dataValues, out dataFrequency);//关键

            //以下代码用IClassifyGEN和EqualInterval对象,基于分段数目,生成各段的临界值,并放在一个数组当中
            IClassifyGEN pClassifyGen = new EqualIntervalClass();
            double[] classes;
            int classCount = 5;
            pClassifyGen.Classify(dataValues, dataFrequency, ref classCount);//用到了上面ITableHistogram生成的值和值频率数组,关键!!!!!!
            classes = pClassifyGen.ClassBreaks as double[];//注意,此对象下标从1开始(我觉得0为最开头,所以临界值从1开始有意义),关键!!!!!!
            //classCount = classes.Length; 此处应该为6
            //for (int i = 0; i < classes.Length; i++)
            //{
            //    MessageBox.Show(classes[i].ToString());
            //}
            //MessageBox.Show(classCount.ToString());

            IClassBreaksRenderer pClassBreakRenderer = new ClassBreaksRendererClass();//设置分段着色属性
            pClassBreakRenderer.Field = "GDP_1999(";
            pClassBreakRenderer.BreakCount = 5;//分成5段
            pClassBreakRenderer.SortClassesAscending = true;

            //以下代码生成颜色带
            IHsvColor pFromColor = getHsvColor(60, 100, 96);
            IHsvColor pToColor = getHsvColor(0, 100, 96);
            IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
            pColorRamp.FromColor = pFromColor as IColor;
            pColorRamp.ToColor = pToColor as IColor;
            pColorRamp.Size = classCount;//生成颜色的数目
            //MessageBox.Show(classCount.ToString());
            bool ok;
            pColorRamp.CreateRamp(out ok);//创建颜色带,关键!!!

            if (ok)//如果颜色带成功生成的话
            {
                IEnumColors pEnumColors = pColorRamp.Colors;//存放生成颜色带的各颜色
                pEnumColors.Reset();//是必须吗?????关键!!!

                IColor pColor;
                ISimpleFillSymbol pSimpleFillSymbol;
                //ISimpleMarkerSymbol pSimpleMarkerSymbol;

                for (int i = 0; i < classCount; i++)//为每个值范围设置符号(此处为SimpleFillSymbol)
                {
                    pColor = pEnumColors.Next();
                    pSimpleFillSymbol = new SimpleFillSymbolClass();
                    pSimpleFillSymbol.Color = pColor;
                    pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                    //pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
                    //pSimpleMarkerSymbol.Color = pColor;
                    pClassBreakRenderer.set_Symbol(i, (ISymbol)pSimpleFillSymbol);//设置Symbol,关键!!!
                    pClassBreakRenderer.set_Break(i, classes[i + 1]);//设置临界值,注意下标,关键!!!
                }

                pGeoFeatLyr.Renderer = pClassBreakRenderer as IFeatureRenderer;
                this.mainMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                //this.axTOCControl.SetBuddyControl(this.mainMapControl.Object);
                this.axTOCControl.Update();
            }
        }
Exemplo n.º 30
0
        public static IRasterRenderer ClassifyRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset pRasterDataset)
        {
            try
            {
                //create the classify render:创建渲染器
                IRasterClassifyColorRampRenderer pClassifyRenderer=new RasterClassifyColorRampRendererClass();
                IRasterRenderer pRasterRenderer=(IRasterRenderer)pClassifyRenderer;
                IRaster pRaster=pRasterDataset.CreateDefaultRaster();
                pRasterRenderer.Raster=pRaster;
                pClassifyRenderer.ClassCount=10;
                pRasterRenderer.Update();

                //创建颜色
                IRgbColor pFromColor=new RgbColorClass();
                pFromColor.Red=255;
                pFromColor.Green=0;
                pFromColor.Blue=0;
                IRgbColor pToColor=new RgbColorClass();
                pToColor.Red=0;
                pToColor.Green=255;
                pToColor.Blue=255;

                //set the color ramp for the symbology:生成色带
                IAlgorithmicColorRamp pRamp=new AlgorithmicColorRampClass();
                pRamp.Size=10;
                pRamp.FromColor=pFromColor;
                pRamp.ToColor=pToColor;
                bool pBoolColorRamp;
                pRamp.CreateRamp(out pBoolColorRamp);
                //create the symbol for the classes.:创建符号
                IFillSymbol pFillSymbol=new SimpleFillSymbolClass();
                for (int i=0;i<pClassifyRenderer.ClassCount;i++){

                    pFillSymbol.Color=pRamp.get_Color(i);
                    pClassifyRenderer.set_Symbol(i,(ISymbol)pFillSymbol);
                    pClassifyRenderer.set_Label(i,Convert.ToString(i));

                }
                return pRasterRenderer;

            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return null;
            }
        }
Exemplo n.º 31
0
        public static IRasterRenderer StretchRender(IRasterDataset pRasterDataset)
        {
            try
            {
                //Define the from and to colors for the color ramp
                IRgbColor pFromColor=new RgbColorClass();
                pFromColor.Red=255;
                pFromColor.Green=0;
                pFromColor.Blue=0;
                IRgbColor pToColor=new RgbColorClass();
                pToColor.Red=0;
                pToColor.Green=255;
                pToColor.Blue=0;

                IAlgorithmicColorRamp pRamp=new AlgorithmicColorRampClass();
                pRamp.Size=10;
                pRamp.FromColor=pFromColor;
                pRamp.ToColor=pToColor;
                bool createColorRamp;
                pRamp.CreateRamp(out createColorRamp);
                //create a stretch renderer
                IRasterStretchColorRampRenderer pStrechRenderer=new RasterStretchColorRampRendererClass();
                IRasterRenderer pRasterRenderer=(IRasterRenderer)pStrechRenderer;
                //set the renderer properties
                IRaster pRaster =pRasterDataset.CreateDefaultRaster();
                pRasterRenderer.Raster=pRaster;
                pRasterRenderer.Update();
                //
                pStrechRenderer.BandIndex=0;
                pStrechRenderer.ColorRamp=pRamp;
                IRasterStretch  pStretchType=(IRasterStretch)pRasterRenderer;
                pStretchType.StretchType=esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                pStretchType.StandardDeviationsParam=2;
                return pRasterRenderer;

            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return null;
            }
        }
Exemplo n.º 32
0
 //创建颜色带
 private IColorRamp CreateAlgorithmicColorRamp(int count)
 {
     //创建一个新AlgorithmicColorRampClass对象
     IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();
     IRgbColor fromColor = new RgbColorClass();
     IRgbColor toColor = new RgbColorClass();
     //创建起始颜色对象
     fromColor.Red = 255;
     fromColor.Green = 0;
     fromColor.Blue = 0;
     //创建终止颜色对象
     toColor.Red = 0;
     toColor.Green = 0;
     toColor.Blue = 255;
     //设置AlgorithmicColorRampClass的起止颜色属性
     algColorRamp.ToColor = fromColor;
     algColorRamp.FromColor = toColor;
     //设置梯度类型
     algColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
     //设置颜色带颜色数量
     algColorRamp.Size = count;
     //创建颜色带
     bool bture = true;
     algColorRamp.CreateRamp(out bture);
     return algColorRamp;
 }
Exemplo n.º 33
0
        private void InitialListViewSymbol(int icounts)
        {
            m_UniqueValuesInfo.lstColor.Clear();
            Color fc = btnFromColor.IsNoColor == true ? Color.White : btnFromColor.SelectedSystemColor;
            IColor fromColor = Convert2ESRIColor(fc);
            Color tc = btnToColor.IsNoColor == true ? Color.Black : btnToColor.SelectedSystemColor;
            IColor toColor = Convert2ESRIColor(tc);

            IAlgorithmicColorRamp nx = new AlgorithmicColorRampClass();
            nx.ToColor = toColor;
            nx.FromColor = fromColor;
            nx.Size = icounts;
            nx.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
            bool isCreated = true;
            nx.CreateRamp(out isCreated);

            IEnumColors hs = nx.Colors;
            IColor color = hs.Next();
            int i = 0;
            while (color != null)
            {
                Color somecolor = ConvertESRI2Color(color);
                m_UniqueValuesInfo.lstColor.Add(somecolor);
                lvwSymbolEx.Items[i++].SubItems[0].BackColor = somecolor;
                color = hs.Next();
            }

            lvwSymbolEx.EndUpdate();
        }
Exemplo n.º 34
0
        //Ϊդ��ͼ�����ݽ���������ɫ
        public static IRasterLayer SetStretchRenderer(IRaster pRaster)
        {
            try
            {
                //������ɫ���QIդ����ɫ
                IRasterStretchColorRampRenderer pStretchRen = new RasterStretchColorRampRendererClass();
                IRasterRenderer pRasRen = pStretchRen as IRasterRenderer;
                //Ϊ��ɫ�͸�������դ������
                pRasRen.Raster = pRaster;
                pRasRen.Update();
                //���������յ���ɫ
                IColor pFromColor = new RgbColorClass();
                IRgbColor pRgbColor = pFromColor as IRgbColor;
                pRgbColor.Red = 255;
                pRgbColor.Green = 0;
                pRgbColor.Blue = 0;
                IColor pToColor = new RgbColorClass();
                pRgbColor = pToColor as IRgbColor;
                pRgbColor.Red = 0;
                pRgbColor.Green = 255;
                pRgbColor.Blue = 0;
                //������ɫ�ּ�
                IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
                pRamp.Size = 255;
                pRamp.FromColor = pFromColor;
                pRamp.ToColor = pToColor;
                bool ok = true;
                pRamp.CreateRamp(out ok);
                //����ɫ�ּ�������ɫ�в�ѡ��һ������
                pStretchRen.BandIndex = 0;
                pStretchRen.ColorRamp = pRamp;
                pRasRen.Update();
                IRasterLayer pRLayer = new RasterLayerClass();
                pRLayer.CreateFromRaster(pRaster);
                pRLayer.Renderer = pStretchRen as IRasterRenderer;
                return pRLayer;

            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
                return null;
            }
        }
Exemplo n.º 35
0
        public ClassRender(AxMapControl pMapControl, IFeatureLayer pFtLayer, int ClassCount, string pFieldName)
        {
            IGeoFeatureLayer pGeolayer;

            IActiveView pActiveView;

            pGeolayer = pFtLayer as IGeoFeatureLayer;

            pActiveView = pMapControl.ActiveView;

            //������Ϊ��ͳ�ƺͷ�������Ҫ�Ķ���

            ITable pTable;

            IClassifyGEN pClassify;//C#Ҫ�������ͬ��VB�еģ��������

            ITableHistogram pTableHist;//�൱��һ��ͳ�Ʊ�

            IBasicHistogram pBasicHist;//���������һ������Ҫ�ķ���

            double[] ClassNum;

            int ClassCountResult;//���ط��������

            IHsvColor pFromColor;

            IHsvColor pToColor;//���ڹ�������һ����ɫ������

            IAlgorithmicColorRamp pAlgo;

            pTable = pGeolayer as ITable;

            IMap pMap;

            pMap = pMapControl.Map;

            pMap.ReferenceScale = 0;

            pBasicHist = new BasicTableHistogramClass();//Ҳ����ʵ���� pTableHist��ѧ���������˼ά

            pTableHist = pBasicHist as ITableHistogram;

            pTableHist.Table = pTable;

            pTableHist.Field = pFieldName;

            object datavalus;

            object Frenquen;

            pBasicHist.GetHistogram(out datavalus,out  Frenquen);//������ݺ���Ӧ��Ƶ����

            pClassify = new EqualIntervalClass();

            try
            {
                pClassify.Classify(datavalus, Frenquen, ref ClassCount);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            // �������

            ClassNum  = (double[])pClassify.ClassBreaks;

            ClassCountResult = ClassNum.GetUpperBound(0);//���طּ�������

            IClassBreaksRenderer pClassBreak;

            pClassBreak = new ClassBreaksRendererClass();

            pClassBreak.Field = pFieldName;

            pClassBreak.BreakCount = ClassCountResult;

            pClassBreak.SortClassesAscending = true;

            pAlgo = new AlgorithmicColorRampClass();

            pAlgo.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;

            pFromColor = Hsv(60, 100, 96);

            pToColor = Hsv(0, 100, 96);

            pAlgo.FromColor = pFromColor;

            pAlgo.ToColor = pToColor;

            pAlgo.Size = ClassCountResult;

            bool ok;

            pAlgo.CreateRamp(out ok);

            IEnumColors pEnumColor;

            pEnumColor = pAlgo.Colors;

            pEnumColor.Reset();

            IColor pColor;

            ISimpleFillSymbol pSimFill;

               /* IRgbColor[] pRgbColor;//���Թ�����ɫ

            pRgbColor = new IRgbColor[ClassCountResult];

            for (int j = 0; j < ClassCountResult; j++)
            {
                int R = 50;

                int G = 100;

                int B = 50;

                R = R + 50;

                if (R > 250)
                {
                    R = 50;
                }
                if (G > 250)
                {
                    G = 100;
                }
                if (B > 250)
                {
                    B = 50;
                }

                G = G + 100;

                B = B + 50;

                pRgbColor[j] = ColorRgb(R, G, B);

            }
            */

            for (int indexColor = 0; indexColor <= ClassCountResult - 1; indexColor++)
            {
                pColor = pEnumColor.Next();

                pSimFill = new SimpleFillSymbolClass();

                 pSimFill.Color = pColor;

               // pSimFill.Color = pRgbColor[indexColor ];

                pSimFill.Style = esriSimpleFillStyle.esriSFSSolid;

                //Ⱦɫ

                pClassBreak.set_Symbol(indexColor, pSimFill as ISymbol);

                pClassBreak.set_Break(indexColor, ClassNum[indexColor + 1]);

            }

            pGeolayer.Renderer = pClassBreak as IFeatureRenderer;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Exemplo n.º 36
0
        public void GraduatedColors(IFeatureLayer pfeatLyr, string sFieldName, int numclasses)
        {
            IGeoFeatureLayer pGeoFeatureL = pfeatLyr as IGeoFeatureLayer;
            object           dataFrequency;
            object           dataValues;
            bool             ok;
            int             breakIndex;
            ITable          pTable          = pGeoFeatureL.FeatureClass as ITable;//各个字段变成一个表
            ITableHistogram pTableHistogram = new BasicTableHistogramClass();
            IBasicHistogram pBasicHistogram = (IBasicHistogram)pTableHistogram;

            pTableHistogram.Field = sFieldName;
            pTableHistogram.Table = pTable;
            pBasicHistogram.GetHistogram(out dataValues, out dataFrequency);//获取渲染值及其出现的频率
            IClassifyGEN pClassify = new EqualIntervalClass();

            pClassify.Classify(dataValues, dataFrequency, ref numclasses);//进行等级划分
            double[]             Classes              = pClassify.ClassBreaks as double[];
            int                  classescount         = Classes.GetUpperBound(0);
            IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass();

            pClassBreaksRenderer.Field                = sFieldName;   //分段字段
            pClassBreaksRenderer.BreakCount           = classescount; //设置分级数目
            pClassBreaksRenderer.SortClassesAscending = true;         //分机后的图例是否按升级顺序排列

            //分级颜色带的开始颜色和结束颜色(即分级颜色在此范围内)
            IHsvColor pFromColor = new HsvColorClass(); //起始颜色

            pFromColor.Hue        = 0;                  //黄色
            pFromColor.Saturation = 50;
            pFromColor.Value      = 96;
            IHsvColor ptocolor = new HsvColorClass(); //终止颜色

            ptocolor.Hue        = 80;                 //不知道什么颜色
            ptocolor.Saturation = 100;
            ptocolor.Value      = 96;


            //产生颜色带对象
            IAlgorithmicColorRamp pAlgorithmicColorRamp = new AlgorithmicColorRampClass();

            pAlgorithmicColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            pAlgorithmicColorRamp.FromColor = pFromColor;
            pAlgorithmicColorRamp.ToColor   = ptocolor;
            pAlgorithmicColorRamp.Size      = classescount;
            pAlgorithmicColorRamp.CreateRamp(out ok);

            //获得颜色
            IEnumColors pEnumColors = pAlgorithmicColorRamp.Colors;

            //symbol和break下标从0开始
            for (breakIndex = 0; breakIndex <= classescount - 1; breakIndex++)
            {
                IColor pColor = pEnumColors.Next();
                switch (pGeoFeatureL.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    ISimpleFillSymbol pSimpleFills = new SimpleFillSymbolClass();
                    pSimpleFills.Color = pColor;
                    pSimpleFills.Style = esriSimpleFillStyle.esriSFSSolid;
                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimpleFills);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    ISimpleLineSymbol pSimplelines = new SimpleLineSymbolClass();
                    pSimplelines.Color = pColor;

                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimplelines);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }

                case esriGeometryType.esriGeometryPoint:
                {
                    ISimpleMarkerSymbol pSimplemaker = new SimpleMarkerSymbolClass();
                    pSimplemaker.Color = pColor;

                    pClassBreaksRenderer.set_Symbol(breakIndex, (ISymbol)pSimplemaker);    //设置填充符号
                    pClassBreaksRenderer.set_Break(breakIndex, Classes[breakIndex + 1]);   //设定每一分级的分级断点
                    break;
                }
                }
            }
            pGeoFeatureL.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
            axMapControl1.Refresh();
            axTOCControl1.Update();
        }
        public ESRI.ArcGIS.Carto.IRasterRenderer Pick(ESRI.ArcGIS.esriSystem.IArray pRenderers, ESRI.ArcGIS.Geodatabase.IRasterDataset pRasterDataset)
        {
            IRasterRenderer rasterRenderer = null;
            IRasterRGBRenderer rasterRGBRenderer = null;
            IRasterStretchColorRampRenderer rasterStretchColorRampRenderer = null;

            // Get the renderers
            int Count = pRenderers.Count;
            int i = 0;
            for (i = 0; i < Count; i++)
            {

                rasterRenderer = (IRasterRenderer)(pRenderers.get_Element(i));

                if (rasterRenderer is IRasterStretchColorRampRenderer)
                {
                    rasterStretchColorRampRenderer = (IRasterStretchColorRampRenderer)rasterRenderer;
                }
                else if (rasterRenderer is IRasterRGBRenderer)
                {
                    rasterRGBRenderer = (IRasterRGBRenderer)rasterRenderer;
                }

            }

            IRasterDataset2 rasterDataset2 = (IRasterDataset2)pRasterDataset;
            IRasterBandCollection rasterBandCollection = (IRasterBandCollection)rasterDataset2;

            if (rasterBandCollection.Count > 5)
            {

                // Use band 4,5 and 3 as red, green and blue
                rasterRenderer = (IRasterRenderer)rasterRGBRenderer;
                rasterRGBRenderer.SetBandIndices(3, 4, 2);
                return (IRasterRenderer)rasterRGBRenderer;

            }
            else // Special stretch
            {

                IRasterBand rasterBand = rasterBandCollection.Item(0);

                bool hasTable = false;
                rasterBand.HasTable(out hasTable);

                if (hasTable == false)
                {

                    // Simply change the color ramp for the stretch renderer
                    //IColor fromColor = new RgbColorClass();
                    //fromColor.RGB = Microsoft.VisualBasic.Information.RGB(255, 200, 50);
                    IColor fromColor = CreateRGBColor(255, 200, 50) as IColor;

                    //IColor toColor = new RgbColorClass();
                    //toColor.RGB = Microsoft.VisualBasic.Information.RGB(180, 125, 0);
                    IColor toColor = CreateRGBColor(180, 125, 0) as IColor;

                    // Create color ramp
                    IAlgorithmicColorRamp algorithmicColorRamp = new AlgorithmicColorRampClass();
                    algorithmicColorRamp.Size = 255;
                    algorithmicColorRamp.FromColor = fromColor;
                    algorithmicColorRamp.ToColor = toColor;
                    bool createRamp = false;
                    algorithmicColorRamp.CreateRamp(out createRamp);

                    if (createRamp == true)
                    {

                        rasterRenderer = (IRasterRenderer)rasterStretchColorRampRenderer;
                        rasterStretchColorRampRenderer.BandIndex = 0;
                        rasterStretchColorRampRenderer.ColorRamp = algorithmicColorRamp;
                        return (IRasterRenderer)rasterStretchColorRampRenderer;

                    }

                }

            }

            return rasterRenderer;
        }
Exemplo n.º 38
0
        private void CreateAlgorimcColorRamps(string strAlgorithm, int intDefault)
        {
            try
            {
                IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();

                switch (strAlgorithm)
                {
                case "HSV":
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                    break;

                case "CIE Lab":
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    break;

                case "Lab LCh":
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                    break;

                default:
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    break;
                }

                IRgbColor pColor1 = new RgbColorClass();
                IRgbColor pColor2 = new RgbColorClass();

                //Can Change the color in here!
                pColor1 = pSnippet.getRGB(arrTotalColors[intRampsCounts, 0], arrTotalColors[intRampsCounts, 1], arrTotalColors[intRampsCounts, 2]);
                pColor2 = pSnippet.getRGB(arrTotalColors[intRampsCounts, 3], arrTotalColors[intRampsCounts, 4], arrTotalColors[intRampsCounts, 5]);

                if (pColor1 == null || pColor2 == null)
                {
                    return;
                }

                Boolean blnOK = true;

                pColorRamp.FromColor = pColor1;
                pColorRamp.ToColor   = pColor2;
                pColorRamp.Size      = intDefault;
                pColorRamp.CreateRamp(out blnOK);

                arrListviewColors = new int[intDefault, 3];
                pEnumColors       = pColorRamp.Colors;
                pEnumColors.Reset();

                for (int k = 0; k < intDefault; k++)
                {
                    IColor    pColor    = pEnumColors.Next();
                    IRgbColor pRGBColor = new RgbColorClass();
                    pRGBColor.RGB = pColor.RGB;

                    arrListviewColors[k, 0] = pRGBColor.Red;
                    arrListviewColors[k, 1] = pRGBColor.Green;
                    arrListviewColors[k, 2] = pRGBColor.Blue;
                }

                pEnumColors.Reset();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Exemplo n.º 39
0
        private void InitialListViewSymbol(List<string> lstCounts,int icounts)
        {
            m_UniqueValuesInfo.lstColor.Clear();
            int classcount = icounts;
            Color fc = btnFromColor.IsNoColor == true ? Color.White : btnFromColor.SelectedSystemColor;
            IColor fromColor = Convert2ESRIColor(fc);
            Color tc = btnToColor.IsNoColor == true ? Color.Black : btnToColor.SelectedSystemColor;
            IColor toColor = Convert2ESRIColor(tc);

            lvwSymbolEx.Items.Clear();
            lvwSymbolEx.BeginUpdate();

            IAlgorithmicColorRamp nx = new AlgorithmicColorRampClass();
            nx.ToColor = toColor;
            nx.FromColor = fromColor;
            nx.Size = classcount;
            nx.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
            bool isCreated = true;
            nx.CreateRamp(out isCreated);

            IEnumColors hs = nx.Colors;
            IColor color = hs.Next();
            int i = 0;
            while (color != null)
            {
                Color somecolor = ConvertESRI2Color(color);
                m_UniqueValuesInfo.lstColor.Add(somecolor);
                string strval = (frmSymbology.m_min +i).ToString();
                string[] strs = new string[] { null, strval, strval,lstCounts[i++]};
                ListViewItem item = new ListViewItem(strs);

                item.SubItems[0].BackColor = somecolor;
                lvwSymbolEx.Items.Add(item);
                color = hs.Next();
            }

            lvwSymbolEx.EndUpdate();
        }
Exemplo n.º 40
0
        private void DynamicCreateRamps(int count, IColor fc, IColor tc)
        {
            deleteTempControls(count);
            int dx = btnFromColor.Location.X + btnFromColor.Width;
            int dy = btnFromColor.Location.Y;

            int dWidth = btnToColor.Location.X - btnFromColor.Location.X - btnToColor.Width;
            int dHeight = btnFromColor.Height;

            int newHeight = dHeight;
            int newWidth = dWidth / count;

            IAlgorithmicColorRamp nx = new AlgorithmicColorRampClass();
            nx.ToColor = tc;
            nx.FromColor = fc;
            nx.Size = count;
            nx.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;

            bool isCreated = true;
            nx.CreateRamp(out isCreated);

            IEnumColors hs = nx.Colors;
            IColor color = hs.Next();
            int i = 0;
            while (color != null)
            {
                //Debug.WriteLine(color.RGB);
                int R = color.RGB & 0xff;
                int G = (color.RGB & 0xff00) / 0x100;
                int B = (color.RGB & 0xff0000) / 0x10000;
                Color somecolor = Color.FromArgb(R, G, B);

                Label p = new Label();
                p.Name = "MyUVPanels" + i.ToString();//���������ƣ������޷���ʾ
                p.Location = new System.Drawing.Point(dx + newWidth * i++, dy);

                p.Size = new System.Drawing.Size(newWidth, newHeight);
                p.BackColor = somecolor;
                this.Controls.Add(p);
                color = hs.Next();
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// Stretchդ����Ⱦ
        /// </summary>
        /// <param name="rasterLayer">դ��ͼ��</param>
        /// <param name="VlaueVMax">Value���ֵ</param>
        /// <param name="VlaueVMin">Value��Сֵ</param>
        /// <param name="fromColor">ɫ�׿�ʼ��ɫ</param>
        /// <param name="toColor">ɫ�׽�����ɫ</param>
        /// <param name="bDisplayBackGroundV">�Ƿ���ʾ����</param>
        /// <param name="BackGroundValue">��ʾ������ֵ</param>
        /// <param name="BackGroundColor">������ɫ</param>
        /// <param name="bUserHillShade">�Ƿ�����Ӱ</param>
        /// <param name="zScale">��ӰZֵ</param>
        /// <param name="nodataColor">Nodata��ɫ</param>
        /// <param name="StretchType">Stretch����</param>
        /// <param name="StretchN">Stretch Nֵ</param>
        /// <param name="bInvert">Stretchֵ�Ƿ�ת</param>
        /// <param name="StatisticsType">ͳ������</param>
        /// <returns></returns>
        private void StretchRenderer(IRasterLayer rasterLayer, string VlaueVMax, string VlaueVMin, string ValueMedium, IColor fromColor, IColor toColor,
            bool bDisplayBackGroundV, double BackGroundValue, IColor BackGroundColor, bool bUserHillShade, Double zScale, IColor nodataColor,
            string StretchType, double StretchN, bool bInvert, string StatisticsType)
        {
            try
            {
                //Create the color ramp.
                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass();
                colorRamp.FromColor = fromColor;
                colorRamp.ToColor = toColor;
                colorRamp.Size = 10;
                bool createColorRamp;
                colorRamp.CreateRamp(out createColorRamp);

                //Create a stretch renderer.
                IRasterStretchColorRampRenderer stretchRenderer = new
                  RasterStretchColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer;

                //Set the renderer properties.
                IRaster raster = rasterLayer.Raster;
                rasterRenderer.Raster = raster;
                rasterRenderer.Update();

                stretchRenderer.BandIndex = 0;
                stretchRenderer.ColorRamp = colorRamp;
                stretchRenderer.LabelLow = VlaueVMin;
                stretchRenderer.LabelHigh =  VlaueVMax;
                stretchRenderer.LabelMedium = ValueMedium;

                (stretchRenderer as IRasterStretchMinMax).UseCustomStretchMinMax = true;

                (stretchRenderer as IHillShadeInfo).UseHillShade = bUserHillShade;
                if (bUserHillShade == true)
                    (stretchRenderer as IHillShadeInfo).ZScale = zScale;

                (stretchRenderer as IRasterStretch2).Background = bDisplayBackGroundV;
                //double dBackGroundValue = 0;
                if (bDisplayBackGroundV == true)
                {
                    (stretchRenderer as IRasterStretch2).BackgroundValue=BackGroundValue;
                    (stretchRenderer as IRasterStretch2).BackgroundColor = BackGroundColor;

                }

                 switch(StretchType)
                {

                    case "NONE":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_NONE;
                        break;
                    case "DefaultFromSource":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_DefaultFromSource;
                        break;
                    case "Custom":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_Custom;
                        break;
                    case "StandardDeviations":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                        break;
                    case "HistogramEqualize":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_HistogramEqualize;
                        break;
                    case "MinimumMaximum":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum;
                        break;
                    case "HistogramSpecification":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_HistogramSpecification;
                        break;
                    case "Count":
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_Count;
                        break;
                     default:
                        (stretchRenderer as IRasterStretch2).StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                         break;

                }
                (stretchRenderer as IRasterStretch2).StandardDeviationsParam = StretchN;

                switch(StatisticsType)
                {
                    case "AreaOfView":
                        (stretchRenderer as IRasterStretch2).StretchStatsType
                            = esriRasterStretchStatsTypeEnum.esriRasterStretchStats_AreaOfView;
                        //IArray ary = (stretchRenderer as IRasterStretch2).StretchStats;

                        //frmSymbology.m_statistics_Min =(double) ary.get_Element(0);
                        //frmSymbology.m_statistics_Max =(double) ary.get_Element(1);
                        //frmSymbology.m_statistics_Mean = (double)ary.get_Element(2);
                        //frmSymbology.m_statistics_stdDev = (double)ary.get_Element(3);
                        break;
                    case "Dataset":
                        (stretchRenderer as IRasterStretch2).StretchStatsType
                            = esriRasterStretchStatsTypeEnum.esriRasterStretchStats_Dataset;
                        break;
                    case "GlobalStats":
                        (stretchRenderer as IRasterStretch2).StretchStatsType
                            = esriRasterStretchStatsTypeEnum.esriRasterStretchStats_GlobalStats;
                        break;
                }

                (stretchRenderer as IRasterStretch2).Invert = bInvert;
                //Set the stretch type.
                //IRasterStretch stretchType = (IRasterStretch)rasterRenderer;
                //stretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
                //stretchType.StandardDeviationsParam = 2;

                rasterLayer.Renderer =stretchRenderer as IRasterRenderer;
                rasterLayer.Draw(esriDrawPhase.esriDPGeography,m_MainMap.ActiveView.ScreenDisplay, null);
                m_MainMap.ActiveView.Refresh();
                m_MainTOC.Update();
                //return rasterRenderer;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return ;
            }
        }
Exemplo n.º 42
0
        private IEnumColors CreateAlgColorRamp(IColor fromColor, IColor toColor, int count)
        {
            IAlgorithmicColorRamp pRampColor = new AlgorithmicColorRampClass();
            pRampColor.FromColor = fromColor;
            pRampColor.ToColor = toColor;
            pRampColor.Size = count;
            bool b = true;
            pRampColor.CreateRamp(out b);

            return pRampColor.Colors;
        }
Exemplo n.º 43
0
        private void InitialListViewSymbol(IList<double> lstBreakValues)
        {
            m_claasifiedInfo.lstColor.Clear();
            int classcount = Convert.ToInt32(cmbClasses.SelectedItem.ToString());
            Color fc = btnFromColor.IsNoColor == true ? Color.White : btnFromColor.SelectedSystemColor;
            IColor fromColor = Convert2ESRIColor(fc);
            Color tc = btnToColor.IsNoColor == true ? Color.Black : btnToColor.SelectedSystemColor;
            IColor toColor = Convert2ESRIColor(tc);

            m_claasifiedInfo.lstBreakValues.Clear();
            lvwSymbolEx.Items.Clear();
            lvwSymbolEx.BeginUpdate();

            IAlgorithmicColorRamp nx = new AlgorithmicColorRampClass();
            nx.ToColor = toColor;
            nx.FromColor = fromColor;
            nx.Size = classcount;
            nx.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
            bool isCreated = true;
            nx.CreateRamp(out isCreated);

            IEnumColors hs = nx.Colors;
            IColor color = hs.Next();

            double dmin = lstBreakValues[0];

            int imax = lstBreakValues.Count-1;
            double dmax = lstBreakValues[imax];
            string sbreak=" - ";

            int i = 0;
            while (color != null)
            {
                Color somecolor = ConvertESRI2Color(color);
                m_claasifiedInfo.lstColor.Add(somecolor);

                double dfrom = frmSymbology.m_min;
                if (i>0)
                {
                    dfrom = lstBreakValues[i - 1];
                }
                double dto = lstBreakValues[i];
                if (dto > dmax)
                    dto = dmax;

                string sfrom = string.Format("{0:0.####}", dfrom);
                string sto = string.Format("{0:0.####}", dto);

                string[] strs = new string[] { null, i.ToString(), sfrom + sbreak + sto, sfrom + sbreak + sto };
                ListViewItem item = new ListViewItem(strs);
                item.SubItems[0].BackColor = somecolor;
                lvwSymbolEx.Items.Add(item);

                m_claasifiedInfo.lstBreakValues.Add(dto);

                i++;
                color = hs.Next();
            }

            lvwSymbolEx.EndUpdate();
        }
Exemplo n.º 44
0
        //Ϊդ��ͼ�����ݰ��մ���Сֵ�����ֵ�ķ�����ɫ
        public static IRasterLayer SetRsLayerClassifiedColor(IRaster pRaster)
        {
            IRasterClassifyColorRampRenderer pClassRen = new RasterClassifyColorRampRendererClass();
            IRasterRenderer pRasRen = pClassRen as RasterClassifyColorRampRendererClass;
            //Set raster for the render and update
            pRasRen.Raster = pRaster;
            pClassRen.ClassCount = 9;
            pRasRen.Update();
            //Create a color ramp to use
            //���������յ���ɫ
            IColor pFromColor = new RgbColorClass();
            IRgbColor pRgbColor = pFromColor as IRgbColor;
            pRgbColor.Red = 255;
            pRgbColor.Green = 200;
            pRgbColor.Blue = 0;
            IColor pToColor = new RgbColorClass();
            pRgbColor = pToColor as IRgbColor;
            pRgbColor.Red = 0;
            pRgbColor.Green = 0;
            pRgbColor.Blue = 255;
            //������ɫ�ּ�
            IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
            pRamp.Size = 9;
            pRamp.FromColor = pFromColor;
            pRamp.ToColor = pToColor;
            bool ok = true;
            pRamp.CreateRamp(out ok);
            //���դ��ͳ����ֵ
            IRasterBandCollection pRsBandCol = pRaster as IRasterBandCollection;
            IRasterBand pRsBand = pRsBandCol.Item(0);
            pRsBand.ComputeStatsAndHist();
            IRasterStatistics pRasterStatistic = pRsBand.Statistics;
            double dMaxValue = pRasterStatistic.Maximum;
            double dMinValue = pRasterStatistic.Minimum;
            //Create symbol for the classes
            IFillSymbol pFSymbol = new SimpleFillSymbolClass();

            double LabelValue = Convert.ToDouble((dMaxValue - dMinValue) / 9);
            for (int i = 0; i <= pClassRen.ClassCount - 1; i++)
            {
                pFSymbol.Color = pRamp.get_Color(i);
                pClassRen.set_Symbol(i, pFSymbol as ISymbol);
                double h1 = (LabelValue * i) + dMinValue;
                double h2 = (LabelValue * (i + 1)) + dMinValue;
                pClassRen.set_Label(i, h1.ToString() + "��" + h2.ToString());
            }
            //Update the renderer and plug into layer
            pRasRen.Update();
            IRasterLayer pRLayer = new RasterLayerClass();
            pRLayer.CreateFromRaster(pRaster);
            pRLayer.Renderer = pClassRen as IRasterRenderer;
            return pRLayer;
        }
Exemplo n.º 45
0
        public ClassRender(AxMapControl pMapControl, String LayerName, int ClassCount, string Field)
        {
            IGeoFeatureLayer pGeolayer;

            ILayer pLayer;

            IActiveView pActiveView;

            IEnumLayer pEnumLayer;

            pEnumLayer = pMapControl.Map.get_Layers(null, true);

            if (pEnumLayer == null)
            {
                return;
            }

            pEnumLayer.Reset();

            int i = 0;

            int LayerIndex = -1;

            for (pLayer = pEnumLayer.Next(); pLayer != null; pLayer = pEnumLayer.Next())
            {
                i++;

                if (pLayer.Name == LayerName)
                {
                    LayerIndex = i - 1;

                    break;
                }
            }

            if (LayerIndex == -1)
            {
                MessageBox.Show("没有找到要渲染的图层");

                return;
            }

            pGeolayer = pMapControl.Map.get_Layer(LayerIndex) as IGeoFeatureLayer;

            pActiveView = pMapControl.ActiveView;

            //以下是为了统计和分类所需要的对象

            ITable pTable;

            IClassifyGEN pClassify;     //C#要用这个不同于VB中的,分类对象。

            ITableHistogram pTableHist; //相当于一个统计表

            IBasicHistogram pBasicHist; //这个对象有一个很重要的方法

            double[] ClassNum;

            int ClassCountResult;//返回分类个数。

            IHsvColor pFromColor;

            IHsvColor pToColor;//用于构建另外一个颜色带对象。

            IAlgorithmicColorRamp pAlgo;

            pTable = pGeolayer as ITable;

            IMap pMap;

            pMap = pMapControl.Map;

            pMap.ReferenceScale = 0;

            pBasicHist = new BasicTableHistogramClass();//也可以实例化 pTableHist。学会这个灵活的思维

            pTableHist = pBasicHist as ITableHistogram;

            pTableHist.Table = pTable;

            pTableHist.Field = Field;

            object datavalus;

            object Frenquen;

            pBasicHist.GetHistogram(out datavalus, out Frenquen);//获得数据和相应的频数。

            pClassify = new EqualIntervalClass();

            try
            {
                pClassify.Classify(datavalus, Frenquen, ref ClassCount);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            // 分类完成

            ClassNum = (double[])pClassify.ClassBreaks;

            ClassCountResult = ClassNum.GetUpperBound(0);//返回分级个数。

            IClassBreaksRenderer pClassBreak;

            pClassBreak = new ClassBreaksRendererClass();

            pClassBreak.Field = Field;

            pClassBreak.BreakCount = ClassCountResult;

            pClassBreak.SortClassesAscending = true;

            pAlgo = new AlgorithmicColorRampClass();

            pAlgo.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;

            pFromColor = Hsv(60, 100, 96);

            pToColor = Hsv(0, 100, 96);

            pAlgo.FromColor = pFromColor;

            pAlgo.ToColor = pToColor;

            pAlgo.Size = ClassCountResult;

            bool ok;

            pAlgo.CreateRamp(out ok);

            IEnumColors pEnumColor;

            pEnumColor = pAlgo.Colors;

            pEnumColor.Reset();

            IColor pColor;

            ISimpleFillSymbol pSimFill;

            /* IRgbColor[] pRgbColor;//可以构造颜色
             *
             * pRgbColor = new IRgbColor[ClassCountResult];
             *
             * for (int j = 0; j < ClassCountResult; j++)
             * {
             *   int R = 50;
             *
             *   int G = 100;
             *
             *   int B = 50;
             *
             *   R = R + 50;
             *
             *   if (R > 250)
             *   {
             *       R = 50;
             *   }
             *   if (G > 250)
             *   {
             *       G = 100;
             *   }
             *   if (B > 250)
             *   {
             *       B = 50;
             *   }
             *
             *   G = G + 100;
             *
             *   B = B + 50;
             *
             *
             *
             *   pRgbColor[j] = ColorRgb(R, G, B);
             *
             * }
             */


            for (int indexColor = 0; indexColor <= ClassCountResult - 1; indexColor++)
            {
                pColor = pEnumColor.Next();

                pSimFill = new SimpleFillSymbolClass();

                pSimFill.Color = pColor;

                // pSimFill.Color = pRgbColor[indexColor ];

                pSimFill.Style = esriSimpleFillStyle.esriSFSSolid;

                //染色

                pClassBreak.set_Symbol(indexColor, pSimFill as ISymbol);

                pClassBreak.set_Break(indexColor, ClassNum[indexColor + 1]);
            }



            pGeolayer.Renderer = pClassBreak as IFeatureRenderer;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

            new MainForm().axTOCControl1.Update();
        }
Exemplo n.º 46
0
        //Ϊդ��ͼ�����ݽ��з�����ɫ
        public static IRasterLayer GetRLayerClassifyColor(IRaster pRaster, double dMaxDis)
        {
            IRasterClassifyColorRampRenderer pClassRen = new RasterClassifyColorRampRendererClass();
            IRasterRenderer pRasRen = pClassRen as RasterClassifyColorRampRendererClass;
            //Set raster for the render and update
            pRasRen.Raster = pRaster;
            pClassRen.ClassCount = 10;
            pRasRen.Update();
            //Create a color ramp to use
            //���������յ���ɫ
            IColor pFromColor = new RgbColorClass();
            IRgbColor pRgbColor = pFromColor as IRgbColor;
            pRgbColor.Red = 255;
            pRgbColor.Green = 0;
            pRgbColor.Blue = 0;
            IColor pToColor = new RgbColorClass();
            pRgbColor = pToColor as IRgbColor;
            pRgbColor.Red = 0;
            pRgbColor.Green = 255;
            pRgbColor.Blue = 0;
            //������ɫ�ּ�
            IAlgorithmicColorRamp pRamp = new AlgorithmicColorRampClass();
            pRamp.Size = 10;
            pRamp.FromColor = pFromColor;
            pRamp.ToColor = pToColor;
            bool ok = true;
            pRamp.CreateRamp(out ok);
            //Create symbol for the classes
            IFillSymbol pFSymbol = new SimpleFillSymbolClass();

            double LabelValue = Convert.ToDouble(dMaxDis / 6);
            for (int i = 0; i <= pClassRen.ClassCount - 1; i++)
            {
                pFSymbol.Color = pRamp.get_Color(i);
                pClassRen.set_Symbol(i, pFSymbol as ISymbol);
                double h1 = LabelValue * i;
                double h2 = LabelValue * (i + 1);
                pClassRen.set_Label(i, h1.ToString() + "��" + h2.ToString());
            }
            //Update the renderer and plug into layer
            pRasRen.Update();
            IRasterLayer pRLayer = new RasterLayerClass();
            pRLayer.CreateFromRaster(pRaster);
            pRLayer.Renderer = pClassRen as IRasterRenderer;
            return pRLayer;
        }
Exemplo n.º 47
0
        //根据起点颜色、终点颜色和级别数目,产生色带
        public List<Color> ProduceColors(Color start, Color end, int gradecount)
        {
            //创建一个新AlgorithmicColorRampClass对象
            IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();
            algColorRamp.ToColor = this.ConvertColorToIColor(end);//从.net的颜色转换
            algColorRamp.FromColor = this.ConvertColorToIColor(start);
            //设置梯度类型
            algColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            //设置颜色带颜色数量
            algColorRamp.Size = gradecount;
            //创建颜色带
            bool bture = true;
            algColorRamp.CreateRamp(out bture);
            //使用IEnumColors获取颜色带
            IEnumColors pEnumColors = algColorRamp.Colors;

            List<Color> result = new List<Color>();
            pEnumColors.Reset();//必须重设
            ESRI.ArcGIS.Display.IColor pC = pEnumColors.Next();
            while (pC != null)
            {
                result.Add(ColorTranslator.FromOle(pC.RGB));//ESRI颜色转换为.net颜色
                pC = pEnumColors.Next();
            }
            return result;
        }
Exemplo n.º 48
0
        private IEnumColors MultiPartColorRamp(string strColorRamp, string strAlgorithm, int intGCBreakeCount)
        {
            try
            {
                IEnumColors pEnumColors = null;

                if (strColorRamp == "Blue Light to Dark" || strColorRamp == "Green Light to Dark" || strColorRamp == "Orange Light to Dark" || strColorRamp == "Red Light to Dark")
                {
                    IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                    switch (strAlgorithm)
                    {
                    case "HSV":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        break;

                    case "CIE Lab":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;

                    case "Lab LCh":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        break;

                    default:
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;
                    }

                    IRgbColor pColor1 = new RgbColor();
                    IRgbColor pColor2 = new RgbColor();

                    switch (strColorRamp)
                    {
                    case "Blue Light to Dark":
                        pColor1 = pSnippet.getRGB(239, 243, 255);
                        pColor2 = pSnippet.getRGB(8, 81, 156);
                        break;

                    case "Green Light to Dark":
                        pColor1 = pSnippet.getRGB(237, 248, 233);
                        pColor2 = pSnippet.getRGB(0, 109, 44);
                        break;

                    case "Orange Light to Dark":
                        pColor1 = pSnippet.getRGB(254, 237, 222);
                        pColor2 = pSnippet.getRGB(166, 54, 3);
                        break;

                    case "Red Light to Dark":
                        pColor1 = pSnippet.getRGB(254, 229, 217);
                        pColor2 = pSnippet.getRGB(165, 15, 21);
                        break;

                    default:
                        pColor1 = pSnippet.getRGB(254, 229, 217);
                        pColor2 = pSnippet.getRGB(165, 15, 21);
                        break;
                    }

                    Boolean blnOK = true;

                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intGCBreakeCount;
                    pColorRamp.CreateRamp(out blnOK);


                    //arrColors = new int [intGCBreakeCount,3];
                    pEnumColors = pColorRamp.Colors;
                }
                else if (strColorRamp == "Custom")
                {
                    Boolean             blnOK           = true;
                    frmColorRamps       m_pColorRamps   = System.Windows.Forms.Application.OpenForms["frmColorRamps"] as frmColorRamps;
                    IMultiPartColorRamp pMultiColorRamp = m_pColorRamps.pMulitColorRampsResults;

                    pMultiColorRamp.Size = intGCBreakeCount;
                    pMultiColorRamp.CreateRamp(out blnOK);


                    pEnumColors = pMultiColorRamp.Colors;
                }
                else
                {
                    IAlgorithmicColorRamp pColorRamp1 = new AlgorithmicColorRampClass();
                    IAlgorithmicColorRamp pColorRamp2 = new AlgorithmicColorRampClass();


                    switch (strAlgorithm)
                    {
                    case "HSV":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        break;

                    case "CIE Lab":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;

                    case "Lab LCh":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        break;

                    default:
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;
                    }

                    IRgbColor pColor1 = new RgbColor();
                    IRgbColor pColor2 = new RgbColor();
                    IRgbColor pColor3 = new RgbColor();

                    switch (strColorRamp)
                    {
                    case "Blue to Red":
                        pColor1 = pSnippet.getRGB(49, 54, 149);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;

                    case "Green to Purple":
                        pColor1 = pSnippet.getRGB(0, 68, 27);
                        pColor2 = pSnippet.getRGB(247, 247, 247);
                        pColor3 = pSnippet.getRGB(64, 0, 75);
                        break;

                    case "Green to Red":
                        pColor1 = pSnippet.getRGB(0, 104, 55);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;

                    case "Purple to Brown":
                        pColor1 = pSnippet.getRGB(45, 0, 75);
                        pColor2 = pSnippet.getRGB(247, 247, 247);
                        pColor3 = pSnippet.getRGB(127, 59, 8);
                        break;

                    default:
                        pColor1 = pSnippet.getRGB(49, 54, 149);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;
                    }


                    pColorRamp1.FromColor = pColor1;
                    pColorRamp1.ToColor   = pColor2;
                    pColorRamp2.FromColor = pColor2;
                    pColorRamp2.ToColor   = pColor3;

                    Boolean blnOK = true;

                    IMultiPartColorRamp pMultiColorRamp = new MultiPartColorRampClass();
                    pMultiColorRamp.Ramp[0] = pColorRamp1;
                    pMultiColorRamp.Ramp[1] = pColorRamp2;
                    pMultiColorRamp.Size    = intGCBreakeCount;
                    pMultiColorRamp.CreateRamp(out blnOK);


                    pEnumColors = pMultiColorRamp.Colors;
                }
                pEnumColors.Reset();
                return(pEnumColors);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message);
                return(null);
            }
        }
Exemplo n.º 49
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboSourceLayer.Text;
                if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "")
                {
                    MessageBox.Show("Assign proper layer and field");
                    return;
                }

                int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                IFeatureClass pFClass = pFLayer.FeatureClass;

                //Create Rendering of Mean Value at Target Layer
                int    intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value);
                string strGCRenderField = cboValueField.Text;

                IGeoFeatureLayer pGeofeatureLayer;
                if (chkNewLayer.Checked == true)
                {
                    IFeatureLayer pflOutput = new FeatureLayerClass();
                    pflOutput.FeatureClass = pFClass;
                    pflOutput.Name         = txtNewLayer.Text;
                    pflOutput.Visible      = true;

                    pGeofeatureLayer = (IGeoFeatureLayer)pflOutput;
                }
                else
                {
                    pGeofeatureLayer = (IGeoFeatureLayer)pFLayer;
                }

                ITable       pTable = (ITable)pFClass;
                IClassifyGEN pClassifyGEN;
                switch (cboGCClassify.Text)
                {
                case "Equal Interval":
                    pClassifyGEN = new EqualIntervalClass();
                    break;

                case "Geometrical Interval":
                    pClassifyGEN = new GeometricalInterval();
                    break;

                case "Natural Breaks":
                    pClassifyGEN = new NaturalBreaksClass();
                    break;

                case "Quantile":
                    pClassifyGEN = new QuantileClass();
                    break;

                case "StandardDeviation":
                    pClassifyGEN = new StandardDeviationClass();
                    break;

                default:
                    pClassifyGEN = new NaturalBreaksClass();
                    break;
                }

                //Need to be changed 1/29/15
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = strGCRenderField;
                pTableHistogram.Table = pTable;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount);

                ClassBreaksRenderer pRender = new ClassBreaksRenderer();
                double[]            cb      = (double[])pClassifyGEN.ClassBreaks;
                pRender.Field        = strGCRenderField;
                pRender.BreakCount   = intGCBreakeCount;
                pRender.MinimumBreak = cb[0];

                //' create our color ramp
                IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                IRgbColor pColor1 = new RgbColor();
                IRgbColor pColor2 = new RgbColor();

                //Can Change the color in here!
                pColor1.Red   = picSymolfrom.BackColor.R;
                pColor1.Green = picSymolfrom.BackColor.G;
                pColor1.Blue  = picSymolfrom.BackColor.B;

                Boolean blnOK = true;
                pColor2.Red          = picSymbolTo.BackColor.R;
                pColor2.Green        = picSymbolTo.BackColor.G;
                pColor2.Blue         = picSymbolTo.BackColor.B;
                pColorRamp.FromColor = pColor1;
                pColorRamp.ToColor   = pColor2;
                pColorRamp.Size      = intGCBreakeCount;
                pColorRamp.CreateRamp(out blnOK);

                IEnumColors pEnumColors = pColorRamp.Colors;
                pEnumColors.Reset();

                IRgbColor pColorOutline = new RgbColor();
                //Can Change the color in here!
                pColorOutline.Red   = picGCLineColor.BackColor.R;
                pColorOutline.Green = picGCLineColor.BackColor.G;
                pColorOutline.Blue  = picGCLineColor.BackColor.B;
                double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value);

                ICartographicLineSymbol pOutLines = new CartographicLineSymbol();
                pOutLines.Width = dblGCOutlineSize;
                pOutLines.Color = (IColor)pColorOutline;

                //' use this interface to set dialog properties
                IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender;
                pUIProperties.ColorRamp = "Custom";

                ISimpleFillSymbol pSimpleFillSym;
                //' be careful, indices are different for the diff lists
                for (int j = 0; j < intGCBreakeCount; j++)
                {
                    pRender.Break[j]          = cb[j + 1];
                    pRender.Label[j]          = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                    pUIProperties.LowBreak[j] = cb[j];
                    pSimpleFillSym            = new SimpleFillSymbolClass();
                    pSimpleFillSym.Color      = pEnumColors.Next();
                    pSimpleFillSym.Outline    = pOutLines;
                    pRender.Symbol[j]         = (ISymbol)pSimpleFillSym;
                }
                pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender;
                if (chkNewLayer.Checked == true)
                {
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                }



                ////* Uncertainty Part *////
                //Declare variables in if parts

                if (tcUncern.SelectedIndex == 0) //Graduated Color
                {
                    int    intUncernBreakCount = Convert.ToInt32(nudCoNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUIColProperties = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    pColorRamp           = new AlgorithmicColorRampClass();
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    pColor1 = new RgbColor();
                    pColor2 = new RgbColor();

                    //Can Change the color in here!
                    pColor1 = pSnippet.getRGB(picCoColorFrom.BackColor.R, picCoColorFrom.BackColor.G, picCoColorFrom.BackColor.B);
                    pColor2 = pSnippet.getRGB(picCoColorTo.BackColor.R, picCoColorTo.BackColor.G, picCoColorTo.BackColor.B);
                    if (pColor1 == null || pColor2 == null)
                    {
                        return;
                    }

                    blnOK = true;
                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intUncernBreakCount;
                    pColorRamp.CreateRamp(out blnOK);

                    pEnumColors = pColorRamp.Colors;
                    pEnumColors.Reset();

                    pColorOutline = pSnippet.getRGB(picCoLineColor.BackColor.R, picCoLineColor.BackColor.G, picCoLineColor.BackColor.B);
                    if (pColorOutline == null)
                    {
                        return;
                    }

                    double dblCoOutlineSize = Convert.ToDouble(nudCoLinewidth.Value);

                    pOutLines       = new CartographicLineSymbol();
                    pOutLines.Width = dblCoOutlineSize;
                    pOutLines.Color = (IColor)pColorOutline;

                    //' use this interface to set dialog properties
                    pUIColProperties           = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    ISimpleMarkerSymbol pSimpleMarkerSym;
                    double dblCoSymSize = Convert.ToDouble(nudCoSymbolSize.Value);
                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]              = cb[j + 1];
                        pRender.Label[j]              = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                        pUIColProperties.LowBreak[j]  = cb[j];
                        pSimpleMarkerSym              = new SimpleMarkerSymbolClass();
                        pSimpleMarkerSym.Size         = dblCoSymSize;
                        pSimpleMarkerSym.Color        = pEnumColors.Next();
                        pSimpleMarkerSym.Outline      = true;
                        pSimpleMarkerSym.OutlineColor = pColorOutline;
                        pSimpleMarkerSym.OutlineSize  = dblCoOutlineSize;
                        pRender.Symbol[j]             = (ISymbol)pSimpleMarkerSym;
                    }

                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 1) //Texture
                {
                    //Create Rendering of Uncertainty at Target Layer
                    int    intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUITexProperties = (IClassBreaksUIProperties)pRender;
                    pUITexProperties.ColorRamp = "Custom";

                    ILineFillSymbol pLineFillSym    = new LineFillSymbolClass();
                    double          dblFromSep      = Convert.ToDouble(nudSeperationFrom.Value);
                    double          dblToSep        = Convert.ToDouble(nudSeperationTo.Value);
                    double          dblInstantSep   = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblFromAngle    = Convert.ToDouble(nudAngleFrom.Value);
                    double          dblToAngle      = Convert.ToDouble(nudAngleFrom.Value); // Remove the angle part (04/16)
                    double          dblInstantAngle = (dblToAngle - dblFromAngle) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblLinewidth    = Convert.ToDouble(nudTeLinewidth.Value);
                    IRgbColor       pLineColor      = new RgbColor();
                    pLineColor.Red   = picTeLineColor.BackColor.R;
                    pLineColor.Green = picTeLineColor.BackColor.G;
                    pLineColor.Blue  = picTeLineColor.BackColor.B;

                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]             = cb[j + 1];
                        pRender.Label[j]             = Math.Round(cb[j], 5).ToString() + " - " + Math.Round(cb[j + 1], 5).ToString();
                        pUITexProperties.LowBreak[j] = cb[j];
                        pLineFillSym                  = new LineFillSymbolClass();
                        pLineFillSym.Angle            = dblFromAngle + (dblInstantAngle * Convert.ToDouble(j));
                        pLineFillSym.Color            = pLineColor;
                        pLineFillSym.Separation       = dblFromSep - (dblInstantSep * Convert.ToDouble(j));
                        pLineFillSym.LineSymbol.Width = dblLinewidth;
                        pRender.Symbol[j]             = (ISymbol)pLineFillSym;
                    }
                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 2) //For Proportional Symbols
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMinPtSize      = Convert.ToDouble(nudProSymbolSize.Value);
                    double dblLineWidth      = Convert.ToDouble(nudProLinewidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    //Find Fields
                    int intUncernIdx = pTable.FindField(strUncerFieldName);

                    //Find Min value
                    //Set to initial value for min
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMinValue  = pStatResults.Minimum;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IRgbColor pSymbolRgb = pSnippet.getRGB(picProSymbolColor.BackColor.R, picProSymbolColor.BackColor.G, picProSymbolColor.BackColor.B);
                    if (pSymbolRgb == null)
                    {
                        return;
                    }

                    IRgbColor pLineRgb = pSnippet.getRGB(picProiLineColor.BackColor.R, picProiLineColor.BackColor.G, picProiLineColor.BackColor.B);
                    if (pLineRgb == null)
                    {
                        return;
                    }

                    ISimpleMarkerSymbol pSMarkerSym = new SimpleMarkerSymbolClass();
                    pSMarkerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                    pSMarkerSym.Size         = dblMinPtSize;
                    pSMarkerSym.OutlineSize  = dblLineWidth;
                    pSMarkerSym.Outline      = true;
                    pSMarkerSym.OutlineColor = (IColor)pLineRgb;
                    pSMarkerSym.Color        = (IColor)pSymbolRgb;

                    IGeoFeatureLayer            pGFLUncern    = (IGeoFeatureLayer)pflUncern;
                    IProportionalSymbolRenderer pUncernRender = new ProportionalSymbolRendererClass();
                    pUncernRender.LegendSymbolCount = 2; //Need to be changed 0219
                    pUncernRender.Field             = strUncerFieldName;
                    pUncernRender.MaxDataValue      = dblMaxValue;
                    pUncernRender.MinDataValue      = dblMinValue;
                    pUncernRender.MinSymbol         = (ISymbol)pSMarkerSym;
                    pUncernRender.ValueUnit         = esriUnits.esriUnknownUnits;
                    pUncernRender.BackgroundSymbol  = null;
                    pUncernRender.CreateLegendSymbols();

                    pGFLUncern.Renderer = (IFeatureRenderer)pUncernRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 3) // Bar
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMaxLength      = Convert.ToDouble(nudMaxBarHeight.Value);
                    double dblBarWidth       = Convert.ToDouble(nudBarWidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    int             intUncernIdx = pTable.FindField(strUncerFieldName);
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IChartRenderer  chartRenderer  = new ChartRendererClass();
                    IRendererFields rendererFields = chartRenderer as IRendererFields;
                    rendererFields.AddField(strUncerFieldName);

                    IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
                    barChartSymbol.Width = dblBarWidth;
                    IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                    markerSymbol.Size = dblMaxLength;
                    IChartSymbol chartSymbol = barChartSymbol as IChartSymbol;
                    chartSymbol.MaxValue = dblMaxValue;
                    ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                    IFillSymbol  fillSymbol  = new SimpleFillSymbolClass();
                    fillSymbol.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    if (fillSymbol.Color == null)
                    {
                        return;
                    }
                    symbolArray.AddSymbol(fillSymbol as ISymbol);

                    if (chk3D.Checked)
                    {
                        I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                        p3DChartSymbol.Display3D = true;
                        p3DChartSymbol.Thickness = 3;
                    }
                    chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol;
                    SimpleFillSymbol pBaseFillSym = new SimpleFillSymbolClass();
                    //pBaseFillSym.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    //chartRenderer.BaseSymbol = pBaseFillSym as ISymbol;
                    chartRenderer.UseOverposter = false;
                    chartRenderer.CreateLegend();
                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    pGFLUncern.Renderer = (IFeatureRenderer)chartRenderer;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                #region illumination
                //This function is not applied in this version. 032317 HK
                //}
                //    else if (tcUncern.SelectedIndex == 4) //illumination
                //    {
                //        frmProgress pfrmProgress = new frmProgress();
                //        pfrmProgress.lblStatus.Text = "Processing:";
                //        pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee;
                //        pfrmProgress.Show();

                //        string strUncerFieldName = cboUField.Text;

                //        IGeoDataset geoDataset_output = createRasterfromPolygon(pFClass, strUncerFieldName, pFLayer, 100);

                //        double altitude = Convert.ToDouble(nudAltitude.Value);
                //        double azimuth = Convert.ToDouble(nudAzimuth.Value);
                //        object zFactor = Convert.ToDouble(nudZFactor.Value);


                //        ISurfaceOp2 pSurfOP = new RasterSurfaceOpClass();
                //        IRaster pOutputDS = (IRaster)pSurfOP.HillShade(geoDataset_output, azimuth, altitude, true, ref zFactor);

                //        ((IDataset)geoDataset_output).Delete();
                //        // Create a raster for viewing
                //        ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = new ESRI.ArcGIS.Carto.RasterLayerClass();
                //        rasterLayer.CreateFromRaster(pOutputDS);

                //        //Calculate hillshade value at slope 0 to set as background value
                //        double dblRadian = (Math.PI / 180) * (90 - altitude);
                //        double dblBackValue = Math.Truncate(255 * Math.Cos(dblRadian));

                //        IRasterStretch pRasterStretch = new RasterStretchColorRampRendererClass();
                //        IColor pColor = new RgbColorClass();
                //        pColor.NullColor = true;
                //        pColor.Transparency = 0;
                //        pRasterStretch.Background = true;
                //        pRasterStretch.BackgroundColor = pColor;
                //        pRasterStretch.set_BackgroundValues(ref dblBackValue);

                //        rasterLayer.Name = "Uncertainty of " + strGCRenderField;
                //        rasterLayer.Renderer = pRasterStretch as IRasterRenderer;
                //        rasterLayer.Renderer.Update();

                //        //Apply Transparency
                //        ILayerEffects pLayerEffect = (ILayerEffects)rasterLayer;
                //        pLayerEffect.Transparency = Convert.ToInt16(nudTransparent.Value);

                //        pfrmProgress.Close();
                //        // Add the raster to the map
                //        pActiveView.FocusMap.AddLayer(rasterLayer);

                //    }

                //    mForm.axMapControl1.ActiveView.Refresh();
                //    mForm.axTOCControl1.Update();
                #endregion
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Exemplo n.º 50
0
        //创建颜色带
        private IColorRamp CreateAlgorithmicColorRamp(int count)
        {
            IAlgorithmicColorRamp algColorRamp = new AlgorithmicColorRampClass();
            IRgbColor fromColor = new RgbColorClass();
            IRgbColor toColor = new RgbColorClass();

            fromColor.Red = 255;
            fromColor.Green = 255;
            fromColor.Blue = 255;

            toColor.Red = 255;
            toColor.Green = 0;
            toColor.Blue = 0;

            algColorRamp.ToColor = toColor;

            algColorRamp.FromColor = fromColor;

            algColorRamp.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;

            algColorRamp.Size = count;

            bool bture = true;
            algColorRamp.CreateRamp(out bture);
            return algColorRamp;
        }
Exemplo n.º 51
0
		//为栅格图层数据进行拉伸着色
		public static IRasterLayer SetStretchRenderer(IRaster pRaster)
		{
			try
			{
				//创建着色类和QI栅格着色
				IRasterStretchColorRampRenderer pStretchRen=new RasterStretchColorRampRendererClass();
				IRasterRenderer pRasRen=pStretchRen as IRasterRenderer;
				//为着色和更新设置栅格数据
				pRasRen.Raster=pRaster;
				pRasRen.Update();
				//定义起点和终点颜色
				IColor pFromColor=new RgbColorClass();
				IRgbColor pRgbColor=pFromColor as IRgbColor;
				pRgbColor.Red=255;
				pRgbColor.Green=0;
				pRgbColor.Blue=0;
				IColor pToColor=new RgbColorClass();
				pRgbColor=pToColor as IRgbColor;
				pRgbColor.Red=0;
				pRgbColor.Green=255;
				pRgbColor.Blue=0;
				//创建颜色分级
				IAlgorithmicColorRamp pRamp=new AlgorithmicColorRampClass();
				pRamp.Size=255;
				pRamp.FromColor=pFromColor;
				pRamp.ToColor=pToColor;
				bool ok=true;
				pRamp.CreateRamp(out ok);
				//把颜色分级插入着色中并选择一个波段
				pStretchRen.BandIndex=0;
				pStretchRen.ColorRamp=pRamp;
				pRasRen.Update();
				IRasterLayer pRLayer=new RasterLayerClass();
				pRLayer.CreateFromRaster(pRaster);
				pRLayer.Renderer = pStretchRen as IRasterRenderer ;
				return pRLayer;	


			}
			catch(Exception ex)
			{
				
				Console.WriteLine(ex.Message);
				return null;
			}
		}