Select to view content in your preferred language

Trouble with IRasterClassifyColorRampRenderer

2066
0
11-07-2014 12:01 PM
SteveCole
Honored Contributor

So, years ago I developed a VBA tool to aid in the visualization of LIDAR data. Essentially, the user provides a "starting" elevation and then the tool quickly applies a Classified renderer to the raster based on the elevation interval the user provides (1 foot, 2 foot, etc). I developed it because doing this manually is a pain and it always requires the generation of statistics before you can even tweak the classified breaks.

All of this worked fine & dandy but lately it's not quite doing what it had in the past. I use the "Temperature" color ramp with my tool and, in the past, all values BELOW the starting elevation would get lumped into the first break of the classification (that makes those rasters have a color of white from that color ramp). On the flip side, all values AFTER the last break got lumped in with the last break's values and are portrayed as dark red.

More recently, this has changed.Now, all values below the starting value specified by the user and all values above the values from the last break in the classified renderer are getting the last color of the renderer (dark red).

How do I set up the IRasterClassifyColorRampRenderer such that all values up to and including the starting value are included in the first break of the renderer and all values after the last break are included in the last break? Working through an example, let's say I have a DEM and I want the renderer to start at elevation 300, have 30 breaks, and use a 1 foot interval between breaks. I want all values < 300 to be white and all values > 330 to be the dark red.

I've attached a screenshot for some context. You can see in the lower left of the data frame that the white color is the elevation I specified for the renderer to start at. Immediately left of the white you see dark red. Those values are BELOW my starting elevation but are portrayed by the color of the last renderer break.

Here's the relevant .NET code from 10.1 (I have excluded some variable initializations for brevity):

            'Create classfy renderer and QI RasterRenderer interface

            pRaster = pRLayer.Raster

            Dim pClassRen As ESRI.ArcGIS.Carto.IRasterClassifyColorRampRenderer

            pClassRen = New ESRI.ArcGIS.Carto.RasterClassifyColorRampRenderer

            Dim pRasRen As ESRI.ArcGIS.Carto.IRasterRenderer

            pRasRen = pClassRen

            'These simple three lines is all you need in order to change the color ramp

            'that is used. They do need to exist shortly after pClassRen is initialized

            'otherwise the specification is ignored..

            Dim pClassProp As ESRI.ArcGIS.Carto.IRasterClassifyUIProperties

            pClassProp = pClassRen

            pClassProp.ColorRamp = "Temperature" 'Name of Ramp from Style Manager

            'Set raster for the render and update

            pRasRen.Raster = pRaster

            pClassRen.ClassCount = numClasses

            pRasRen.ResamplingType = ESRI.ArcGIS.Geodatabase.rstResamplingTypes.RSP_BilinearInterpolation 'Set to Bilinear Interpretation

            'pRasRen.Update()

            'loop through the classes and update the label

            For I = 0 To pClassRen.ClassCount - 1

                pClassRen.Break(I) = curElev

                Select Case I

                    Case 0

                        pClassRen.Label(I) = "< " & CStr(curElev) & " Feet"

                    Case pClassRen.ClassCount - 1

                        pClassRen.Label(I) = "> " & CStr(curElev) & " Feet"

                    Case Else

                        pClassRen.Label(I) = CStr(curElev) & " - " & CStr(curElev + theInterval)

                End Select

                curElev = curElev + theInterval

            Next I

            'Update the renderer and plug into layer

            pRasRen.Update()

            pRLayer.Renderer = pClassRen

            pMxDoc.ActiveView.Refresh()

            pMxDoc.UpdateContents()

Thanks!

Steve

0 Kudos
0 Replies