mimiller

updating layer symbology

Discussion created by mimiller on Apr 20, 2012
I'm wondering if there is another way of updating layer symbolgy other than UpdateLayer()?

I'm using the following code (a snippett from my script) to update a layer first to a feature class and attempting the second time to update the symbology. When the layer is added to the map doc, it uses default symbology. Attempting to change the symbology so it appears correct in the published map service. Anyone have any ideas?


# update the merged points layer in map document to feature class in GeoDataBase
# this needs to be done in order to create msd file and publish to the server 
updatePointLayer = arcpy.mapping.ListLayers(mxd, addedPointLayer, df)[0]
sourcePointLayer = arcpy.mapping.Layer(fc_merged_points)
arcpy.mapping.UpdateLayer(df, updatePointLayer, sourcePointLayer, False) # updates the data source to feature class
#arcpy.mapping.MapDocument.save(mxd)
print "Updated point layer in map document to feature class(" + fc_merged_points + ")"
arcpy.AddMessage("Updated point layer in map document to feature class(" + fc_merged_points + "")

# update the symbology of points  ######Not functioning correctly#######
#updatePointLayer = arcpy.mapping.ListLayers(mxd, addedPointLayer, df)[0]
sourcePointLayer2 = arcpy.mapping.Layer(pointSymbology)
arcpy.mapping.UpdateLayer(df, updatePointLayer, sourcePointLayer2, True) #updates symbology only
#arcpy.mapping.MapDocument.save(mxd)
print "Updated point symbology in map document using (" + pointSymbology + ")"
arcpy.AddMessage("Updated point symbology in map document using (" + pointSymbology + ")")


Michael Miller

Outcomes