[GIS] Applying Symbology to group layer using ArcPy

arcpygroup-layersymbology

I currently have around 200 features that all need have the same symbology applied to them. I have used the ApplySymbologyfromlayer_management however this takes much to long to process, at least a few hours and the labels arent brought across either.

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
inputlayers = ['ST13003-00108100-009','ST13003-00116584-073','ST13003-00115372-080','ST13003-00112948-011','ST13003-00111736-021','ST13003-00122544-083','ST13003-00099716-018']
symbologylayer = 'Layer'

for layer in inputlayers:
    arcpy.ApplySymbologyFromLayer_management(layer, symbologylayer)

This works however justs takes way to long.

What I want to do export all lines from ArcMap as a layer or layer package and apply the symbology across all of the features without doing this manually.

When I try this however this error occurs.

Runtime error Trace back (most recent call last): File "",
line 1, in File "c:\program files
(x86)\arcgis\desktop10.1\arcpy\arcpy\management.py", line 5696, in
ApplySymbologyFromLayer raise e ExecuteError: ERROR 000967: The
input layer type must be a feature layer, raster layer, or tin layer.

I looked at creating Representations, is that the solution or is there another way around this?

Best Answer

Using ListLayers will help you in this task, especially if you want to apply this changes to all of the layers in the map document. In the question, arcpy is only seeing a list of text values, not layers. This will help get you to the FOR loop for the layers.

Set the symbology layers as you want it and save it. Reference it with a absolute path or set the arcpy.env.workspace environment setting to that directory.

Related Question