The code runs, but the output layers do not display the symbology layer(s). Any suggestions?

def Copy_Symbology( Symbology_Template , Input_SHP , Output_Layer_Directory ):
    baseName = os.path.basename( Input_SHP )
    layerName = baseName.split('.')[0]

    #Create the object that references where to save the output LAYER FILES 
    Output_Layer_File_Path =  os.path.join( Output_Layer_Directory,  name + ".lyr")

    # Process: Make Feature Layer
    arcpy.MakeFeatureLayer_management( Input_SHP, layerName )

    # Process: Apply Symbology From Layer
    arcpy.ApplySymbologyFromLayer_management( layerName, Symbology_Template )

    # Process: Save To Layer File
    arcpy.SaveToLayerFile_management( layerName, Output_Layer_File_Path )

#Set workspace:
arcpy.env.workspace = r'M:\PCC\GEO242\Final Project\womenrule.gdb'
arcpy.env.overwriteOutput = True

wksp = r'M:\PCC\GEO242\Final Project\womenrule.gdb'
states_shp = r'M:\PCC\GEO242\Final 
laws_csv = r'M:\PCC\GEO242\Final Project\womenrule.gdb\womenrights'
Output_Layer_Directory = r'M:\PCC\GEO242\Final Project'

#Join csv to US shp:
lyr_states = arcpy.MakeFeatureLayer_management(states_shp, "ustates")
join_shp2csv = arcpy.AddJoin_management(lyr_states, "STUSPS", laws_csv, "State", "KEEP_COMMON")
shp_states = arcpy.CopyFeatures_management(join_shp2csv, r'M:\PCC\GEO242\Final Project\womenrule.gdb\final_states')
lyr_final_states = arcpy.MakeFeatureLayer_management(r'M:\PCC\GEO242\Final Project\womenrule.gdb\final_states' , 'final_states')

#Iterate through attributes to create new lyr files:
ref_lyr = r'M:\PCC\GEO242\Final Project\SymbolTemp.lyr'
ref_lyr1 = r'M:\PCC\GEO242\Final Project\SymbolTemp1.lyr'
ref_lyr2 = r'M:\PCC\GEO242\Final Project\SymbolTemp2.lyr'

field_names = [f.name for f in arcpy.ListFields(lyr_final_states)]
for name in field_names:
    if name == "womenrights_Male":
       Copy_Symbology( ref_lyr1, 'final_states', Output_Layer_Directory )
    elif name == "womenrights_Female":
       Copy_Symbology( ref_lyr1, 'final_states', Output_Layer_Directory ) 
    elif name == "womenrights_Earnings_Ratio":
       Copy_Symbology( ref_lyr2, 'final_states', Output_Layer_Directory )
       Copy_Symbology( ref_lyr, 'final_states', Output_Layer_Directory )

print "Done!"  
  • Welcome to GIS SE. Thank you for taking the Tour. Please edit the question to state what does occur. It would not be remiss to add some diagnostic output and report what is displayed. The title should summarize the question, not provide the only mention of your task. – Vince Jun 9 '18 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.