I have an ArcPy script to apply the symbology of one raster layer to all of the raster layers in the table of contents. I have used this script before with feature layers instead of raster layers, and it worked perfectly. Now when I run it, it runs continuously and it does not change the symbology of any of the raster layers in the table of contents. It does not give me any error messages; the window appears, saying that it successfully changed the symbology. Also, it works when I manually apply the symbology of one raster layer to the other layers in the table of contents. The script seems to iterate through the list without actually changing anything.
[GIS] Apply Symbology to Rasters using Arcpy Script
arcpyrastersymbology
Best Answer
There's a few minor hiccups in your code, I've re-written it (hopefully) better:
This assumes that the data frame called Georgia exists in the current mxd, if it doesn't then you'll have problems. I've added a condition for isRasterLayer in case you've got mixed feature/raster/group layers - note, you might want to include the layer.isBroken as well if you've got unreferenced layers (red exclamation marks).
I have changed the script and tested it; this version works on ArcGis 10.1:
I have commented out lines that don't suit my environment...
It is possible that it's having issues running from the python window so I set up the code to run from a toolbox, copy and paste the code into notepad, save as .py file then create a new toolbox in Catalog and add the script with one parameter:
Layer to match
, typeLayer File
.In ArcMap run the tool from the toolbox (in catalog view is fine) and it will apply the symbology from the layer file.. to get the original layer file right click on the correct symbology layer and select 'Save As Layer File'.