I am trying to use ArcObjects (Visual Basic) to loop through the map layers in an ArcGIS desktop *.mxd document and read the renderers that are attached to the existing layers (want to use Raster layers). Can anyone tell me how to read (not set ) the property of a layer (or data set) which renderer is attached to it currently ? I found tons of examples how to set a renderer it but I need instead to read what is set already. The next step I need to get the b colors for the classes in the renderer. If anyone has a code example (no matter which programming language that would be terrific
Thanks Karsten
The following VBA code shows you how to get a handle on a raster layers renderer:
Public Sub test() ' Get document Dim pmxd As IMxDocument Set pmxd = ThisDocument ' Get map Dim pmap As IMap Set pmap = pmxd.FocusMap ' Get first layer (assumed to be raster) Dim pLayer As ILayer Set pLayer = pmap.Layer(0) ' QI into rasterlayer Dim pRasterLayer As IRasterLayer Set pRasterLayer = pLayer ' Get renderer Dim pRasterRenderer As IRasterRenderer Set pRasterRenderer = pRasterLayer.Renderer ' Test renderer type and report If TypeOf pRasterRenderer Is IRasterStretchColorRampRenderer Then Debug.Print "stretchy!" Dim pRasterStretchColorRampRenderer As IRasterStretchColorRampRenderer Set pRasterStretchColorRampRenderer = pRasterRenderer Debug.Print pRasterStretchColorRampRenderer.LabelHigh End If End Sub
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.