1

I have a layer where I have symbolized the features on unique values. I have also grouped several features together. EX) Layer: Land Use; Value Field: Type of Land Use; Unique Values of different park types have been grouped together and there 'Label' changed to "Parks"; All other unique values left the same.

Using ArcPy 10.2, how can I print the "Label" (not the unique value itself) of the Unique Value categorization? I am looking for something where I can use arcpy.mappings?

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 12, 2015 at 18:55

3 Answers 3

3

Use classLabels from the UniqueValuesSymbology class

mxd = arcpy.mapping.MapDocument(path_to_your_mxd)
lyr = arcpy.mapping.ListLayers(m)[0]
print(lyr.symbology.classLabels)

Relevant documentation: http://resources.arcgis.com/en/help/main/10.2/index.html#/UniqueValuesSymbology/00s30000005s000000/

answered May 12, 2015 at 20:17
0
0

Is it possible to change the layer label, from arcpy, in a simple symbol layer?

enter image description here

I have this code, and want to change something in it, to do what i want. It only changes the layer name.

import arcpy 
from arcpy import env 
env.workspace = r"C:\temp\python" 
for mxdFile in arcpy.ListFiles("*.mxd"): 
 mxdPath = env.workspace + "\\" + mxdFile 
 mxd = arcpy.mapping.MapDocument(mxdPath) 
 layers = arcpy.mapping.ListLayers(mxd) 
 for lyr in layers: 
 if lyr.name == "something to change": 
 lyr.name = "changed name" 
 arcpy.RefreshTOC() 
answered Mar 15, 2017 at 20:16
0
0

I figured how to do what I needed up here. I just need to change it, the way I want one time, then save a .lyr from the correct information (it can also change symbology, and other stuff).

The script below, will apply the .lyr file to your layer in the TOC. You just must specify the name of the layer, like displayed in TOC.

It will do to all MXD files, in the same folder of the script.

import arcpy, os
from arcpy import env 
env.workspace = os.curdir
 
for mxdFile in arcpy.ListFiles("*.mxd"): 
 mxdPath = env.workspace + "\\" + mxdFile 
 mxd = arcpy.mapping.MapDocument(mxdPath) 
 layers = arcpy.mapping.ListLayers(mxd) 
 
 for lyr in layers: 
 if lyr.name == "layer_name_in_TOC": #change here
 print mxdPath
 symbologyLayer = r"D:\LayerFile.lyr" #change here
 arcpy.ApplySymbologyFromLayer_management (lyr, symbologyLayer) 
 arcpy.RefreshTOC()
 mxd.save()
Keggering
1,1371 gold badge8 silver badges27 bronze badges
answered Mar 16, 2017 at 13:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.