Exemple #1
0
        public static IRasterRenderer CreateSlopePrecentRiseColorRamp(Raster gRaster)
        {
            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
                IRaster         raster         = rasterDataset.CreateDefaultRaster();

                rasterRenderer.Raster       = raster;
                classifyRenderer.ClassCount = 10;
                rasterRenderer.Update();
                classifyRenderer.Break[0] = 0;
                classifyRenderer.Label[0] = "0 to 3.5%";
                classifyRenderer.Break[1] = 3.5;
                classifyRenderer.Label[1] = "3.5% to 8.75%";
                classifyRenderer.Break[2] = 8.75;
                classifyRenderer.Label[2] = "8.75% to 15%";
                classifyRenderer.Break[3] = 15;
                classifyRenderer.Label[3] = "15% to 25%";
                classifyRenderer.Break[4] = 25;
                classifyRenderer.Label[4] = "25% to 45%";
                classifyRenderer.Break[5] = 45;
                classifyRenderer.Label[5] = "45% to 70%";
                classifyRenderer.Break[6] = 70;
                classifyRenderer.Label[6] = "70% to 100%";
                classifyRenderer.Break[7] = 100;
                classifyRenderer.Label[7] = "100% to 175%";
                classifyRenderer.Break[8] = 175;
                classifyRenderer.Label[8] = "175% to 565%";
                classifyRenderer.Break[9] = 565;
                classifyRenderer.Label[9] = "> 565%";
                List <RgbColor> lColors    = CreateSlopeColorRamp();
                IFillSymbol     fillSymbol = new SimpleFillSymbolClass();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }

                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemple #2
0
        public static IRasterRenderer CreateGrainSizeStatisticColorRamp(GCDConsoleLib.Raster gRaster, UnitsNet.Units.LengthUnit eUnits)
        {
            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
                IRaster         raster         = rasterDataset.CreateDefaultRaster();

                rasterRenderer.Raster       = raster;
                classifyRenderer.ClassCount = 5;
                rasterRenderer.Update();
                classifyRenderer.Break[0] = 0;
                classifyRenderer.Label[0] = "Fines, Sand (0 to 2 mm)";
                classifyRenderer.Break[1] = UnitsNet.Length.From(2, UnitsNet.Units.LengthUnit.Millimeter).As(eUnits);
                classifyRenderer.Label[1] = "Fine Gravel (2 mm to 16 mm)";
                classifyRenderer.Break[2] = UnitsNet.Length.From(16, UnitsNet.Units.LengthUnit.Millimeter).As(eUnits);
                classifyRenderer.Label[2] = "Coarse Gravel (16 mm to 64 mm)";
                classifyRenderer.Break[3] = UnitsNet.Length.From(64, UnitsNet.Units.LengthUnit.Millimeter).As(eUnits);
                classifyRenderer.Label[3] = "Cobbles (64 mm to 256 mm)";
                classifyRenderer.Break[4] = UnitsNet.Length.From(256, UnitsNet.Units.LengthUnit.Millimeter).As(eUnits);
                classifyRenderer.Label[4] = "Boulders (> 256 mm)";

                List <RgbColor> lColors = new List <RgbColor>();
                lColors.Add(CreateRGBColor(194, 82, 60));
                lColors.Add(CreateRGBColor(240, 180, 17));
                lColors.Add(CreateRGBColor(123, 237, 0));
                lColors.Add(CreateRGBColor(27, 168, 124));
                lColors.Add(CreateRGBColor(11, 44, 122));

                IFillSymbol fillSymbol = new SimpleFillSymbol();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }

                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemple #3
0
        public static IRasterRenderer CreateClassifyRenderer(GCDConsoleLib.Raster gRaster, int iClassCount, string sColorRampName, double dMax, bool bInvert = false)
        {
            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
                IFillSymbol     fillSymbol     = new SimpleFillSymbol();
                IRaster         raster         = rasterDataset.CreateDefaultRaster();

                rasterRenderer.Raster = raster;
                IColorRamp        pColorRamp;
                IStyleGalleryItem pStyleItem = GetESRIStyleColorRamp(out pColorRamp, sColorRampName);
                classifyRenderer.ClassCount = iClassCount;
                rasterRenderer.Update();
                CreateClassBreaks(dMax, iClassCount, classifyRenderer);
                pColorRamp.Size = iClassCount;
                bool bOK = false;
                pColorRamp.CreateRamp(out bOK);
                List <IColor> lColors = new List <IColor>();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    lColors.Add(pColorRamp.Color[i]);
                }

                if (bInvert)
                {
                    lColors.Reverse();
                }

                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }

                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemple #4
0
        public static IRasterRenderer CreateDoDClassifyRenderer(Raster gRaster, int iClassCount, double rampRange)
        {
            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
                IFillSymbol     fillSymbol     = new SimpleFillSymbolClass();
                IRaster         raster         = rasterDataset.CreateDefaultRaster();

                double rMin = -2.5;
                double rMax = 2.5;
                if (rampRange == 0)
                {
                    gRaster.ComputeStatistics();
                    Dictionary <string, decimal> rasterStats = gRaster.GetStatistics();
                    rMin = (double)rasterStats["min"];
                    rMax = (double)rasterStats["max"];
                }
                else
                {
                    rMin = rampRange * -1;
                    rMax = rampRange;
                }

                rasterRenderer.Raster = raster;
                if ((rMin == double.MinValue & rMax == double.MaxValue) | (rMin == double.MaxValue & rMax == double.MinValue) | (rMin == float.MinValue & rMax == float.MaxValue) | (rMin == float.MaxValue & rMax == float.MinValue))
                {
                    classifyRenderer.ClassCount = 1;
                    ESRI.ArcGIS.Display.IRgbColor rgbColor = CreateRGBColor(255, 255, 255);
                    rgbColor.Transparency      = 0;
                    fillSymbol.Color           = rgbColor;
                    classifyRenderer.Symbol[0] = (ISymbol)fillSymbol;
                    classifyRenderer.Label[0]  = "No Data (no change detected)";
                    return(rasterRenderer);
                }

                classifyRenderer.ClassCount = iClassCount;
                rasterRenderer.Update();
                CreateDoDClassBreaks(rMax, rMin, iClassCount, ref classifyRenderer);
                List <IColor> lColors = CreateDoDColorRamp();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }

                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Exemple #5
0
        public static IRasterRenderer CreateSlopeDegreesColorRamp(GCDConsoleLib.Raster gRaster)
        {
            IRasterRenderer rasterRenderer = null;

            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                // Create the classify renderer
                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                rasterRenderer = (IRasterRenderer)classifyRenderer;
                IRaster raster = rasterDataset.CreateDefaultRaster();
                rasterRenderer.Raster       = raster;
                classifyRenderer.ClassCount = 10;
                rasterRenderer.Update();

                classifyRenderer.Break[0]  = (double)gRaster.GetStatistics()["min"];
                classifyRenderer.Label[0]  = "0 to 2";
                classifyRenderer.Break[1]  = 2;
                classifyRenderer.Label[1]  = "2 to 5";
                classifyRenderer.Break[2]  = 5;
                classifyRenderer.Label[2]  = "5 to 10";
                classifyRenderer.Break[3]  = 10;
                classifyRenderer.Label[3]  = "10 to 15";
                classifyRenderer.Break[4]  = 15;
                classifyRenderer.Label[4]  = "15 to 25";
                classifyRenderer.Break[5]  = 25;
                classifyRenderer.Label[5]  = "25 to 35";
                classifyRenderer.Break[6]  = 35;
                classifyRenderer.Label[6]  = "35 to 45";
                classifyRenderer.Break[7]  = 45;
                classifyRenderer.Label[7]  = "45 to 60";
                classifyRenderer.Break[8]  = 60;
                classifyRenderer.Label[8]  = "60 to 80";
                classifyRenderer.Break[9]  = 80;
                classifyRenderer.Label[9]  = "80 to 90";
                classifyRenderer.Break[10] = 90;

                //Create the symbol for the classes.
                List <RgbColor> lColors    = CreateSlopeColorRamp();
                IFillSymbol     fillSymbol = new SimpleFillSymbolClass();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                rasterRenderer = null;
            }

            return(rasterRenderer);
        }
Exemple #6
0
        public static IRasterRenderer CreateRoughnessColorRamp(GCDConsoleLib.Raster gRaster)
        {
            try
            {
                // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
                IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
                ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
                rasterDataset.PrecalculateStats(0);
                ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
                pRastBand.ComputeStatsAndHist();

                IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
                IRaster         raster         = rasterDataset.CreateDefaultRaster();

                rasterRenderer.Raster       = raster;
                classifyRenderer.ClassCount = 10;
                rasterRenderer.Update();
                classifyRenderer.Break[0] = 0;
                classifyRenderer.Label[0] = "0 to 0.1";
                classifyRenderer.Break[1] = 0.1;
                classifyRenderer.Label[1] = "0.1 to 0.25";
                classifyRenderer.Break[2] = 0.25;
                classifyRenderer.Label[2] = "0.25 to 0.5";
                classifyRenderer.Break[3] = 0.5;
                classifyRenderer.Label[3] = "0.5 to 0.75";
                classifyRenderer.Break[4] = 0.75;
                classifyRenderer.Label[4] = "0.75 to 1.0";
                classifyRenderer.Break[5] = 1;
                classifyRenderer.Label[5] = "1.0 to 1.5";
                classifyRenderer.Break[6] = 1.5;
                classifyRenderer.Label[6] = "1.5 to 2.0";
                classifyRenderer.Break[7] = 2;
                classifyRenderer.Label[7] = "2.0 to 3.0";
                classifyRenderer.Break[8] = 3;
                classifyRenderer.Label[8] = "3.0 to 5.0";
                classifyRenderer.Break[9] = 5;
                classifyRenderer.Label[9] = "> 5.0";

                List <RgbColor> lColors = new List <RgbColor>();
                lColors.Add(CreateRGBColor(255, 255, 179));
                lColors.Add(CreateRGBColor(252, 241, 167));
                lColors.Add(CreateRGBColor(252, 230, 157));
                lColors.Add(CreateRGBColor(250, 218, 145));
                lColors.Add(CreateRGBColor(250, 208, 135));
                lColors.Add(CreateRGBColor(237, 191, 126));
                lColors.Add(CreateRGBColor(219, 167, 118));
                lColors.Add(CreateRGBColor(201, 147, 111));
                lColors.Add(CreateRGBColor(184, 127, 106));
                lColors.Add(CreateRGBColor(166, 101, 101));

                IFillSymbol fillSymbol = new SimpleFillSymbol();
                for (int i = 0; i < classifyRenderer.ClassCount; i++)
                {
                    fillSymbol.Color           = lColors[i];
                    classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
                }

                return(rasterRenderer);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }