I've looked at a number of sources and from what I gather, it seems like the only way I can apply a symbology is to do the following:

  1. Manually create a layer file that has the symbology I want already applied.
  2. Apply the symbology from the created feature layer using the arcpy.ApplySymbologyFromLayer_Management function.

This is what I have in code so far to do the above:

mxd = arcpy.mapping.MapDocument(MAP_PATH)

data_frame = arcpy.mapping.ListDataFrames(mxd)[0]

for layer in arcpy.mapping.ListLayers(mxd):
    symbol_name = path_to_symbol_layer_file
    temp_layer_name = layer.name





del mxd

I'd prefer to keep my symbologies organized in a single .style file and apply each one directly, without having to create a layer file for it. Is this not possible with arcpy?

In other words, in pseudo-code, I want something like:

style = arcpy.Style('/path/to/foo.style')

mxd = arcpy.mapping.MapDocument('/path/to/bar.mxd')

for layer in arcpy.ListLayers(mxd):
  symbology = arcpy.GetSymbology(style, "custom_symbology_%s" % layer.name)

  arcpy.ApplySymbology(layer, symbology)


del mxd
  • I think you can appy unqiue symbols from a style file using the mapping library. I may be misunderstanding what you are trying to achieve. See here: desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/… – dslamb Sep 24 '19 at 19:55
  • If I understand your question correctly, you may want to use the settings -> style manager menu. – Kartograaf Sep 24 '19 at 20:01
  • Why create a temporary layer? Can't you save each style as a layer, and then use the arcpy.ApplySymbologyFromLayer_Management? I do that (not using arcpy, but import symbol tool) and it works flawlessly. – Gustavo Sep 24 '19 at 20:01
  • I've updated my question with some pseudo-code that roughly depicts what I'm trying to achieve. Hopefully it clarifies things. – CJ Virtucio Sep 24 '19 at 20:25
  • That's right, there's no need to create the temporary layer for the symbology. I've updated my question with the code I have so far. – CJ Virtucio Sep 25 '19 at 14:03

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.