classified by Definedinterval. No interval changes.

1661
0
11-19-2012 07:09 PM
stilramber
New Contributor
I have a grid. I need to display it is classified by DefinedInterval. Method is set to normal, and the interval is calculated by itself.
  In the description of the method is said that you first need to set the interval and then assign method (?), But how is not clear.

code:
Public Function ClassifyRenderer1(ByVal rasterDataset As ESRI.ArcGIS.Geodatabase.IRasterDataset, nummeclass As Integer) As IRasterRenderer
         Try
            'Create the classify renderer.
            Dim classifyRenderer As IRasterClassifyColorRampRenderer = New RasterClassifyColorRampRendererClass()
              classifyRenderer.ClassCount = nummeclass
            Dim rasterRenderer As IRasterRenderer = CType(classifyRenderer, IRasterRenderer)

            'Set up the renderer properties.
            Dim raster As IRaster = rasterDataset.CreateDefaultRaster()
            rasterRenderer.Raster = raster
            Dim pRasterBC As IRasterBandCollection = CType(rasterRenderer.Raster, IRasterBandCollection)
              Dim pRasterBand As IRasterBand = pRasterBC.Item(0)
            pRasterBand.ComputeStatsAndHist()
            classifyRenderer.ClassCount = nummeclass
            rasterRenderer.Update()



            'set classfication method
            Dim pClassProp As IRasterClassifyUIProperties
            pClassProp = classifyRenderer
            Dim pUID As UID
            Dim ClassBreak As Object
            Dim pClassify As IClassifyGEN
            pClassify = New DefinedInterval
            Dim pInterval As IIntervalRange2 = pClassify
            pInterval.IntervalRange = 25
            ClassBreak = pClassify.ClassBreaks
            pUID = pClassify.ClassID
            pClassProp.ClassificationMethod = pUID
            rasterRenderer = classifyRenderer
            rasterRenderer.Update()


            'Set the color ramp for the symbology.
            Dim colorRamp As IAlgorithmicColorRamp = New AlgorithmicColorRampClass
              Dim startColor As IRgbColor
            Dim endColor As IRgbColor
            startColor = New RgbColor
            endColor = New RgbColor
            startColor.Red = 209
            startColor.Green = 144
            startColor.Blue = 21
            endColor.Red = 7
            endColor.Green = 218
            endColor.Blue = 7
            'Set the Start and End
            'Colorsalg()
            colorRamp.ToColor = startColor
            'alg()
            colorRamp.FromColor = endColor
            'Set the ramping Alglorithm alg
            colorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm
            'Set the size of the ramp (the number of colors to be derived)alg
            colorRamp.Size = nummeclass
            'Create the rampalg
            colorRamp.CreateRamp(True)
            ' Dim createColorRamp As Boolean
            'colorRamp.CreateRamp(createColorRamp)

            'Create the symbol for the classes.
            Dim fillSymbol As IFillSymbol = New SimpleFillSymbolClass()
            Dim pFSymbol As IFillSymbol
            pFSymbol = New SimpleFillSymbol

            Dim i As Integer
            For i = 0 To classifyRenderer.ClassCount - 1 Step i + 1
               pFSymbol.Color = colorRamp.Color(i)
               classifyRenderer.Symbol(i) = CType(pFSymbol, ISymbol)
               ' classifyRenderer.Label(i) = Convert.ToString(i)
            Next
            Return rasterRenderer
        Catch ex As Exception
            System.Diagnostics.Debug.WriteLine(ex.Message)
            Return Nothing
        End Try
    End Function
0 Kudos
0 Replies