Sunday 1 September 2019

arcgis 10.2 - Changing color of symbol in UniqueValuesSymbology object using ArcPy?


I have an template mxd I reference with several pre-defined layers. The only variable I need to modify is the color of certain symbols in the layer. I have tried to modify and dig around the Symbology Object but I cannot access the colors of each Unique Value Symbol.


This is how I am accessing the the Symbology of the individual layers. There doesn't seem to be and option to change the color a value.





  • I am using ArcGIS 10.2.1


    mxd_file = r"some\path\file.mxd"
    mxd = arcpy.mapping.MapDocument(mxd_file)

    # getting data frame
    df = arcpy.mapping.ListDataFrames(mxd)[0]

    # getting street layer

    street_layer = arcpy.mapping.ListLayers(mxd, 'Street', df)[0]

    if street_layer.symbologyType == 'UNIQUE_VALUES':
    # trying to access all possible properties of the symbology object
    street_symbology = street_layer.symbology
    desc = street_symbology.classDescription
    labels = street_symbology.classLabels
    values = street_symbology.classValues
    show_other_values = street_symbology.showOtherValues
    value_field = street_symbology.valueField

    del mxd, df

    layer_file = r"some\path\file.lyr"
    arcpy.SaveToLayerFile_management(path_layer, layer_file)



Answer



I agree with the comment by @Hornbydd:



The short answer is no. The only way I am aware using the standard geo-processing tools is to use the Apply Symbology From Layer tool. It may be possible to access the Symbology using python to drive ArcObjects, you would have to do some research on that.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...