-1

When I ran my arcpy script from the python prompt, the ApplySymbologyFromLayer_management worked fine using just the layer names for the parameters. Same thing when running that tool from ArcMap itself. However... when I run it from an arcpy script, it does not work. It does not support providing full paths to the layers (e.g. the .mdb files that they are in). So, how do the parameters to ApplySymbologyFromLayer_management() have to be specified? Do they have to be somewhere special to be found with just the short names?

Traceback (most recent call last):
  File "G:\...\Toolboxes\SEOWellsShlBorepath.py", line 116, in <module>
    arcpy.ApplySymbologyFromLayer_management(in_layer=dss_prefix + cleaned_val, in_symbology_layer="APD_SHL_Half_Mile_Buffer")
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 6955, in ApplySymbologyFromLayer
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Layer: Dataset dss_4375_3_15_NH does not exist or is not supported
Failed to execute (ApplySymbologyFromLayer).

dss_prefix = "dss_"

cleaned_val = "4375_3_15_NH"

1
  • Please edit your question to include a snippet of the actual code you tested that is producing the error.
    – Midavalo
    Commented Dec 22, 2017 at 15:15

1 Answer 1

2

Apply symbology from a layer, whilst using a script or modelbuilder, requires you to use a LYR file for this to work. You cannot simply specify a featureclass or shapefile, as this does not hold the relevant symbology definitions. This information is held within an LYR file.

Each layer (LYR file) references a dataset and specifies how that dataset is portrayed using symbols and text labels

ArcMap automatically applies symbology when you drag datasets into the ArcMap window. Therefore when using this tool within ArcMap, it does not require you to use an LYR file.

LYR files are created through the ArcMap window or through a geoprocessing tool.

Please see the following links for more information:

What is a Layer?

Apply Symbology from Layer tool.

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