Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

problem with ApplySymbologyFromLayer_management not applying symbology

$
0
0
I am running ArcGIS v10.1. Here is a snippet of my arcpy code. I am trying to apply symbology to point features. The layer to display and my symbology layer both have the attribute "DESCRIPT" to match to. I can apply the symbology manually in ArcMap, but when I try this code, it does not do it, even with a screen refresh. Any ideas as to the problem? The screen capture shows the layer added to the top of the TOC.

Thanks.
Karl
_______________

layerName = "crime_95"
outFeature = "crimejoinKK.shp"
crimeLayer = "crimejoinLayer"
symbologyLayer = r"C:\temp\CrimeTypes.lyr"
crimeType = "CrimeTypes"


#Process: Copy layer
# Copy the crime layer to a new permanent feature class
arcpy.CopyFeatures_management(layerName, outFeature)


# First, Add Field - need to add a field that will match the field in the symbology layer
arcpy.AddField_management(outFeature, "DESCRIPT", "TEXT")
# Then Calculate Field - calculate the field with the crime descriptions
arcpy.CalculateField_management(outFeature, "DESCRIPT", "[crime95d_9]", "VB", "")
# Make a temporary layer to apply the symbology to
arcpy.MakeFeatureLayer_management(outFeature, crimeLayer)

#BELOW IS WHERE THE PROBLEM IS.
#I am adding crimeLayer to the data frame, then applying symbology to it.
#The point symbols show up, but not the symbology applied to them.

addCrimeLayer = arcpy.mapping.Layer(crimeLayer)
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
arcpy.mapping.AddLayer(df, addCrimeLayer, "TOP")
arcpy.ApplySymbologyFromLayer_management(addCrimeLayer, symbologyLayer)
arcpy.RefreshActiveView()

----------
Attachment 22229
Attached Thumbnails
Click image for larger version

Name:	result of applysymbologyfromlayer.jpg‎
Views:	N/A
Size:	33.0 KB
ID:	22229  

Viewing all articles
Browse latest Browse all 2485

Trending Articles