2

I am working with 16-bit signed raster image mosaic dataset in ArcGIS Pro 2.9.0. I use Attribute Table function to specify classes' names using external table:

enter image description here

While this function works and gives me the classes I want, it uses random colormap for classes. I would like to use specified colormap. In the Attribute Table function however, you can insert classes' names manually and then change the colors from there:

enter image description here

Can you specify color by RGB or hex in the text file, so it would work in this function using external table?

I tried, as in the function description: using a table to name and symbolize the values in a dataset, where columns for the table are comma delimited: PixelValue, AttributeName, RedValue, GreenValue, BlueValue, but it didn't give me desired result.

It doesn't work with additional function Colormap, because then it changes names of the classes (and they can be only numeric, so it doesn't allow me to name them "> x months"). It also doesn't work for me while trying to export as raster function template. Therefore, I am looking for the solution that would allow me to specify color in the text file and use it as an external table in the Attribute Table function. Something like this, but working:

enter image description here

2 Answers 2

0

To do this I think you need to investigate Attribute-driven color in symbology:

You can customize feature symbols by leveraging data attributes as symbol property values. When you work with color properties in symbols, there are some additional considerations because there are many ways to dynamically define colors.

2
  • I cannot Vary symbology by attribute because I simply do not have this tab in the Symbology pane. I guess because it is raster data?
    – Joanna
    Dec 2, 2021 at 8:28
  • I’ve only tried it with vector data and am not in a position to test a raster attribute table tonight.
    – PolyGeo
    Dec 2, 2021 at 11:27
0

You can use the CIM module to access a raster layers symbology and tweak just about every aspect of it. So for example I spoofed up this demo raster to be similar to what you want:

Sample

To access the first label and its symbol I used this code:

p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
l = m.listLayers('test.tif')[0]
l_cim = l.getDefinition('V2')
c = l_cim.colorizer
grps = c.groups
ruvg = grps[0]
fc = ruvg.classes[0]  # You could place this bit in a loop to access all classes
fc.label= "0 m"  # Updated label
fc.color.values = [255,123,444,100] # Some desired RGB colour
l.setDefinition(l_cim)  # Write back changes to layer

The results are this:

Results

This minimum code should get you going. I would strongly recommend you install the CIM viewer addin as this is really useful for viewing the object model of the layer and which properties can be changed. How to use the viewer is discussed here to download an ArcPro 3.x compatible addin you need to download it from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.