[GIS] Changing color and transparency of layer using ArcPy

arcgis-10.1arcpysymbology

I would like to create an ArcPy script to change the color and transparency of a collection of layers.

The color and transparency would be based on wildcards such as "_dog" or "_chicken".

The layer symbology is "single symbol" and the transparency will be a constant percentage for the color.

The problem I encountered, how do I change the color and transparency of the layer?

I can't find any code samples or documentation to point me in the right direction.

I found a post that suggests this is not possible with ArcPy … hopefully that's incorrect.

Best Answer

You can't really change the symbology of a layer in arcpy with the level of customization you have when just right clicking a layer and using the symbology menu. However, you can make a "template" layer that contains the symbology you want and then use ApplySymbologyFromLayer_management (in_layer, in_symbology_layer). This will allow you to apply the symbology for any layer with that of the "template". Then you can use:

yourLayer = arcpy.mapping.Layer(r'path to your layer') 
yourLayer.transparency = 50 #as a percentage
Related Question