0

I'm trying to automate a map, and one of those tasks is to set a specific symbology for a feature class. I create the feature class of Subject and Comps in the code, then add it to the map, then when I try to add the symbology created previously, it gives me an error

ERROR 000732: Input Layer: Dataset C:\ArcMap\Res_Parcels.gdb\Subject does not exist or is not supported Failed to execute (ApplySymbologyFromLayer)

arcpy.env.overwriteOutput = True
# Set layer to apply symbology to
inputLayer1 = "C:\ArcMap\Res_Boulder.gdb\Subject"
inputLayer2 = "C:\ArcMap\Res_Boulder.gdb\Comps"
# Set layer that output symbology will be based on
symbologyLayer1 = "C:\ArcMap\Comps.lyr"
symbologyLayer2 = "C:\ArcMap\Subject.lyr"
# Apply the symbology from the symbology layer to the input layer
arcpy.ApplySymbologyFromLayer_management (inputLayer1, symbologyLayer1)
arcpy.ApplySymbologyFromLayer_management (inputLayer2, symbologyLayer2)
1
  • 2
    You're trying to apply symbology to a feature class, not a layer. You'll need to find the layer in your mxd with code such as arcpy.mapping.ListLayers. Sep 19, 2019 at 19:05

2 Answers 2

2

Looks like it is having trouble finding the files.

I use double backslash to get to my files. "C:\\ArcMap\\Res_Boulder.gdb\\Subject"

See this reference which shows the valid and invalid path options https://pro.arcgis.com/en/pro-app/arcpy/get-started/setting-paths-to-data.htm

0

Emil's comment assisted me with finding an answer. My code has me create a layer based on a selection, so using that layer, and pre-setting up a .lyr with the symbology I wanted, I was able to make it work.

sym = arcpy.mapping.ListLayers(mxd, "Subject", df)[0]
sym1 = arcpy.mapping.ListLayers(mxd, "Comps", df)[0]

# Set layer that output symbology will be based on
symbologyLayer1 = r'C:\ArcMap\Comps.lyr'
symbologyLayer2 = r'C:\ArcMap\Subject.lyr'
# Apply the symbology from the symbology layer to the input layer
arcpy.ApplySymbologyFromLayer_management(sym, symbologyLayer2)
arcpy.ApplySymbologyFromLayer_management(sym1, symbologyLayer1)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.