AnsweredAssumed Answered

How to change the dynamic text tag for maximum value in a field using Arcpy.mp?

Question asked by Gil.Grodzinsky_GAEPD on Oct 16, 2020
Latest reply on Oct 18, 2020 by manishpatelesriaustralia-com-au-esridist

Hi Everyone: I have successfully produced a map with title, legend and statistics (number, maximum, minimum, mean). I did this within ArcPro through the desktop application, creating a template. Now I want to produce many maps, but only changing the column of data or "field" in the corresponding attribute table. I only having issues with the statistics (number, maximum, minimum, mean) where the field does not change even when the map plots do (so I have the title, legend and the map colors for each polygon on the map updating to the newer column through an earlier command "sym.renderer.classificationField = 'Sheet4.NEI2014v_1'  "  which switched it from the NEI2014v2_ field. This command appears to not impact the text statistics (number, max, min, mean) which are based on the listElements module under "TEXT_ELEMENT".

 

The dynamic text tag reads as follows: Maximum: <dyn type="table" property="max" mapFrame="Map Frame" mapMemberUri="CIMPATH=map/cb_2018_us_county_500k.xml" isDynamic="true" field="Sheet4.NEI2014v2_" decimalPlaces="2" separator="true"/>

 

In Arcpy.mp, I am able to print out this text out with:

aprx = arcpy.mp.ArcGISProject(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/SavedOutput7014.aprx')
m=aprx.listMaps("Map")[0]
l = m.listLayers()[2]
Layout = aprx.listLayouts("Layout")[0]

five=Layout.listElements("TEXT_ELEMENT",'Text 2')[0]

print(five.text)

 

And it produced:
Maximum: <dyn type="table" property="max" mapFrame="Map Frame" mapMemberUri="CIMPATH=map/cb_2018_us_county_500k.xml" isDynamic="true" field="Sheet4.NEI2014v2_" decimalPlaces="2" separator="true"/>

 

Don't worry about the above coding, other than this is how I confirmed this is indeed the contents of this Text Element on the Layout I am working on.  What I want to do in my program is change the dynamic text tag so the field changes to a different column of values in the attribute table ("field" is the column title on the attribute table), specifically from "Sheet4.NEI2014v2_" to "Sheet4.NEI2014v_1".  So if I typed "print(five.text) again, it would show field="Sheet.NEI2014v_1" instead in the dynamic text tag.

I searched around and can't find the correct command or coding to have the dynamic text tag change the "field"

It is simply typing in a box in the ArcPro desktop app, but I want to mass produce this through Arcpy.mp (or at least be able to produce a dozen at a time for this case). 

 

Thanks so much for your input!

 

 

Gil

Outcomes