Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Trying to print classLables in symbology type UNIQUE VALUES

$
0
0

I have a classified image of 10 classes stacked together. Once I put them into ArcMap they don’t appear as 10 individual classes, they look like one big class.

enter image description here

When I click on unique values the following is the result
enter image description here

Once I compute the unique values the 10 classes are created
enter image description here

After adding all the values these 10 classes appear on table of content
enter image description here

I am trying to do the similar process through arcpy script, but I could not find any methods which could enable me to do the same.


import arcpy
... mxd = arcpy.mapping.MapDocument("current")
... lyr = arcpy.mapping.ListLayers(mxd, "IDSI_2002.img - Layer_1")[0]
... if lyr.symbologyType == "UNIQUE_VALUES":
... #lyr.symbology.valueField = "SUB_REGION"
... #lyr.symbology.addAllValues()
... print "we are not able to reach here"
... print (lyr.symbology.classLables)
...
... print (lyr.symbology.classLables)
... arcpy.RefreshActiveView()
... arcpy.RefreshTOC()
... del mxd

My layer has unique values but still it is now able to show Lables or Values if i try to print Lables without checking the for UNIQUE_VALUES it gives the following error


Runtime error
Traceback (most recent call last):
File "<string>", line 10, in <module>
File "c:program files (x86)arcgisdesktop10.3arcpyarcpyarcobjects_base.py", line 78, in _get
(attr_name, self.__class__.__name__))
NameError: The attribute 'symbology' is not supported on this instance of Layer.


Viewing all articles
Browse latest Browse all 767

Trending Articles