Whenever I perform the Summarize Within tool in ArcGIS Pro and use the graduated colors symbology on the resulting feature class, I end up with something that looks like this:
Is there a way to remove all those zeros? In other words can I set the results to zero decimal places using Arcpy for ArcGIS Pro?
Solved! Go to Solution.
I used the following code to get the results I was looking for:
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
lyr = m.listLayers("layer_name")[0]
sym = lyr.symbology
if sym.renderer == "GraduatedColorsRenderer":
breaks = sym.renderer.classBreaks
for b in breaks:
b_int = b.label[0:-7]
b.label = b_int
lyr.symbology= sym
You can begin within the ClassBreak section. I don't know how far down you can burrow to find out if they can be set to an integer value. I don't know how far along you have gotten. Is there a need to use python and arcpy for this?
Yes I need to use arcpy because I want to implement it into a larger script
http://pro.arcgis.com/en/pro-app/arcpy/mapping/classbreak-class.htm but according to the code sample you have to format the labels yourself, which can be done using standard python formatting with the appropriate decimal specifier
a = 10000.0
"{:2.0f}".format(a) # '10000'
"{:2.1f}".format(a) # '10000.0'
"{:2.2f}".format(a) # '10000.00'
I used the following code to get the results I was looking for:
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
lyr = m.listLayers("layer_name")[0]
sym = lyr.symbology
if sym.renderer == "GraduatedColorsRenderer":
breaks = sym.renderer.classBreaks
for b in breaks:
b_int = b.label[0:-7]
b.label = b_int
lyr.symbology= sym