I am a student using PyCharm connected to ArcGIS Pro Python and using ArcGIS 3.0.3 provided by my school.
I am currently trying to apply a symbology layer to a polygon layer using arcpy.management.ApplySymbologyFromLayer() to change it. The script finishes without any errors, but the symbology is not applied. I've read a few posts complaining about similar issues.
I currently have two scripts: one for exporting a layer and the other that uses arcpy.management.ApplySymbologyFromLayer()
import arcpy
arcpy.env.workspace = r"D:\__ŠKOLA__\Střední\Gis\PROJECT_SCRIPT\PROJECT_SCRIPT\PROJECT_SCRIPT.gdb"
layer_name = "ExportedLayer"
in_symbology_layer = r"D:\__ŠKOLA__\Střední\Gis\PROJECT_SCRIPT\PROJECT_SCRIPT\ExportedLayer.lyrx"
# Výběr vrstvy
input_layer = "polygon"
attribute_field = "PO"
try:
arcpy.management.ApplySymbologyFromLayer(layer_name, in_symbology_layer, [["VALUE_FIELD", "PO", "PO"]], "UPDATE")
print("Symbology applied successfully.")
except Exception as e:
print(f"Error: {e}")
If you are doing this with pro open, did you try refreshing the map?
If you are just running the script with pro closed, nothing will happen since the project would have to be saved with the changes.
A bit more discussion on the surrounding methodology you are using might help narrow down other issues
I have ArcGIS Pro open. I tried closing and reopening it as well. I wanted to refresh the map but couldn't find a designated button for it, so I tried closing and reopening the map, thinking it would work like a refresh.
your instance of python isn't connected to Pro if you aren't running the script from the python window or a tool being run from within Pro, so your map has no clue what is going on around it. Either attach the script to a tool in Pro and and run the tool, or try running your code from within a Pro notebook or the python window in Pro