AnsweredAssumed Answered

arcpy.map symbology - why do I need "saveACopy"?

Question asked by kenta215ok0 on Nov 6, 2018
Latest reply on Nov 7, 2018 by kenta215ok0

Hi,

I'm using arcpy.mp module, and facing some basic concerns. I would really appreciate if anyone could help out with this.

I ran the code below, and it worked fine. I want to symbolyze the point feature class as graduated color with 5 quantile here.

But I wonder why the last sentence "aprx.saveACopy(r"C:\Users\kenta\Documents\ArcGIS\Projects\CoHRE_Collaboration\Output.aprx)" is needed. I want my code be reflected on the project defined as "aprx", but it is not possible? Do I always need to do saveACopy to reflect the symbology changes? Thank you so much for your help!

 

import arcpy,os
from arcpy import env
env.overwriteOutput = True
env.workspace = r"C:\Users\kenta\Documents\ArcGIS\Projects\CoHRE_Collaboration\CoHRE_Collaboration.gdb"

# First, reference the project
aprx = arcpy.mp.ArcGISProject(r"C:\Users\kenta\Documents\ArcGIS\Projects\CoHRE_Collaboration\CoHRE_Collaboration.aprx")

m = aprx.listMaps("Oki")[0]
lyr = m.listLayers("oki2018_point")[0]
if lyr.isFeatureLayer:
sym = lyr.symbology
if hasattr(sym, 'renderer'):
sym.renderer.classificationField = 'SMI2'
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationMethod = 'Quantile'
sym.renderer.breakCount = 5
lyr.symbology = sym
aprx.saveACopy(r"C:\Users\kenta\Documents\ArcGIS\Projects\CoHRE_Collaboration\Output.aprx")

Outcomes