2

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.

1

2 Answers 2

5

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
4

It is not possible to change the properties of a layer directly. The properties of a layer can be changed, but only by importing properties from another layer in the map or a layer file. Even the layer name cannot be changed without an existing layer or layer file. "UpdateLayer" in the ArcGIS Help can give you more details and some examples.

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.