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.
-
you can set the transparency of a layer with arcpy: resources.arcgis.com/en/help/main/10.1/index.html#//…JasonBK– JasonBK2015年05月18日 16:59:21 +00:00Commented May 18, 2015 at 16:59
2 Answers 2
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
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.