starbuck23@live.com

UpdateLayer symbology

Discussion created by starbuck23@live.com on Jun 25, 2011
Latest reply on Jun 29, 2011 by starbuck23@live.com
I am trying to use  source_layers to update layers in a different mxd. The layers I am wanting to update are Rivers_1, Rivers_2, Rivers_3, Roads_1, Roads_2, Roads_3, and Buildings_1, Buildings_2, Buildings_3. The previous layers are in the mxd called final project.  The source layers I am using for the update are River, Roads, Buildings, these layers are from the source.gdb I have included the following script I used and the error I am getting. What I am trying to do is use the smybology from the source layers to replace the symbology for the layers in the final project mxd.

import arcpy
mxd = arcpy.mapping.MapDocument (r"D:\GIS_6340_Customization\starbuck.j\Final Project\final project.mxd")
df = arcpy.mapping.ListDataFrames (mxd, "final project")
updateLayer = arcpy.mapping.ListLayers (mxd, "River_1", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "River_2", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "River_3", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "Roads_1", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "Roads_2", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "Buildings_1", df) 
updateLauer = arcpy.mapping.ListLayers (mxd, "Buildings_2", df) 
updateLayer = arcpy.mapping.ListLayers (mxd, "Buildings_3", df)
sourceLayer = arcpy.mapping.Layer (r"D:\GIS_6340_Customization\starbuck.j\Final Project\Source.mxd\River.lyr")
sourcrLayer = arcpy.mapping.Layer (r"D:\GIS_6340_Customization\starbuck.j\Final Project\Source.mxd\Road.lyr")
sourceLayer = arcpy.mapping.Layer (r"D:\GIS_6340_Customization\starbuck.j\Final Project\Source.mxd\Buildings.lyr")
arcpy.mapping.UpdateLayer (df, updateLayer, sourceLayer, True)
mxd.saveACopy (r"D:\GIS_6340_Customization\starbuck.j\Final Project\Revised.mxd")

Error:
Traceback (most recent call last):
  File "D:\GIS_6340_Customization\starbuck.j\Final Project\Symbology.py", line 12, in <module>
    sourceLayer = arcpy.mapping.Layer (r"D:\GIS_6340_Customization\starbuck.j\Final Project\Source.mxd\River.lyr")
  File "D:\Desktop10.0\ArcPy\arcpy\arcobjects\mixins.py", line 256, in __init__
    super(LayerMixin, self).__init__(lyrfile)
  File "D:\Desktop10.0\ArcPy\arcpy\arcobjects\_base.py", line 47, in __init__
    for arg in args))
ValueError: Object: CreateObject Layer invalid data source

Outcomes