Select to view content in your preferred language

Legend label rounding with Python in ArcGIS Pro

279
0
02-29-2024 11:47 AM
KITEfejlesztes
New Contributor

In a legend of feature layer, I would like to format the subtitle so that it doesn't print the full number, but rounds the category limits to 2 decimal places. I want to implement the format shown in the image not manually, but within a python script. I am using ArcGIS Pro 3.2 version. 

Maybe with a CIM tool can solve this? So far I haven't found an example script how.

49251242-f66c-484b-ae97-8f6ed59f7272.png

 

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
lyr5 = m.addDataFromPath(elev)
sym5 = lyr5.symbology
if hasattr(sym5, 'renderer'):
    if sym5.renderer.type == 'SimpleRenderer':
        sym5.updateRenderer("GraduatedColorsRenderer")
        sym5.renderer.classificationField = "Elevation"
        sym5.renderer.colorRamp = aprx.listColorRamps("Elevation #3")[0]
        sym5.renderer.breakCount = 10
        lyr5.symbology = sym5

 

 

 

 

Tags (3)
0 Kudos
0 Replies