Changing Symbology of Multiple Layers using ArcMap/ArcPy?
I had the same problem and I found another solution. It is simple and really practical, it doesn’t even need the creation of a *.lyr file.
In ArcGIS ModelBuilder editor box, I designed the below process:
- Create a variable, defining the data type to ‘layer’. In its properties set as “a list of values” and “Model parameter”. (Optional: Rename the object to “Layers to symbolize”, to an easier identification).
- Create a variable, defining the data type to ‘layer’. In its properties set as “Model parameter”. (Optional: Rename it to “Symbology Layer”).
- Add the Tool “Apply Symbology From Layer”, usually in ‘C:\Program Files\ArcGIS\Desktop10.2\ArcToolbox\Toolboxes\ Data Management Tools.tbx\Layers and Table Views’. (Optional: Rename the output object to “Symbolized Layers”).
- In Properties of the tool ‘Apply Symbology From Layer’ check as Preconditions: “Layers to symbolize” and “Symbology Layer”.
- Connect “Layers to symbolize” to the tool setting it as Input Layer.
- Connect “Symbology Layer” to the tool setting it as Input Layer.
- Save and close the model editor window.
- Opening the model, a table will appear.
- Drag the layer to be used as symbology's template, from the table of contents (TOC) of map project and drop it in the respective table field. Click ‘check values’ button.
- Select multiple layers of the TOC, drag and drop them to respective table field. Click ‘check values’ button.
- Run it.
- Click F5 to refresh the map display.
Notes: It will probably not work if you use at the same time layers of different types of geometries. It does not work well if you use at once layers with the same name. I did not tried with non vector layers.
The exported script to python of the model is:
# Import arcpy module
import arcpy
# Script arguments
Layers_to_symbolize = arcpy.GetParameterAsText(0)
Symbology_Layer = arcpy.GetParameterAsText(1)
# Local variables:
Symbolized_Layers = Layers_to_symbolize
# Process: Apply Symbology From Layer
arcpy.ApplySymbologyFromLayer_management(Layers_to_symbolize, Symbology_Layer)
Edit You can use this script provided by ESRI to complete the task at hand (same idea as below):
import arcpy
arcpy.ApplySymbologyFromLayer_management("in_layer", "in_symbology_layer")
in_layer : The layer to which the symbology will be applied.
Feature Layer;Raster Layer; TIN Layer;Network Analysis Layerin_symbology_layer : The symbology of this layer is applied to the Input Layer.
Feature Layer; Raster Layer;TIN Layer; Network Analysis Layer
Or extend this in the form of standalone scripting (think IDLE):
import arcpy
from arcpy import env
# Set the current workspace
env.workspace = "path/to/workspace"
# Set layer to apply symbology to
inputLayers = ["in_layer_first.lyr","in_layer_second.lyr","in_layer_third.lyr"]
# Set layer that output symbology will be based on
symbologyLayer = "in_symbology_layer.lyr"
# Apply the symbology from the symbology layer to the input layer
for layer in inputLayers:
arcpy.ApplySymbologyFromLayer_management (layer, symbologyLayer)
In essence, you create a symbology layer (in_symbology_layer) that you maintain with respect to design/style. Then you copy that layers symbology on to each of your other layers as listed in your table of contents.
Previous Answer
You can use a style from a current layer in your table of contents/layer list and apply it to your other layers.
For each subsequent layer (below your intended style layer) > right click > properties > symbology > import style from other layer
Just prior to @Aaron s message, I used the information from @Roy to create my own solution that I could incorporate into am ArcToolbox script. See below:
# Import modules
import arcpy
#Get the current Map Document
mxd = arcpy.mapping.MapDocument("CURRENT")
# Script arguments
Template_Layer = arcpy.GetParameterAsText(0)
LayerList = arcpy.GetParameterAsText(1)
Layers_to_Symbolize = LayerList.split(";")
# Process: Apply Symbology From Layer
for UpdateLayer in Layers_to_Symbolize:
arcpy.AddMessage("Updating: " + UpdateLayer)
arcpy.ApplySymbologyFromLayer_management(UpdateLayer,Template_Layer)
# Refresh the Table of Contents to reflect the change
arcpy.RefreshTOC()
#Delete the MXD from memory
del mxd
I could see this concept as a potential tool for a 10.1 Python Add-in on the toolbar.