Select to view content in your preferred language

Modify Static Text in ArcGIS Pro Report with Python

08-04-2023 08:12 PM
Labels (3)
New Contributor III

I have a report in ArcGIS Pro 3.1.2. The basis of the report is just to list address information of those addresses that fall within a certain distance(half and one mile buffers) of a well. For the past few years I have manually created the maps and reports when requested.  So the requester would send me information about a new well, including the xy coordinates of it's location.  I would then add the well to our features, create the buffers, update and create the map (utilizing data series), and then create each report of the addresses that fall within each buffer. Not too bad or time consuming, but since I had some free time, I thought I'd automate the process.

So I wrote a script in Python (3.6) that reads an Excel Spreadsheet of the well information, creates the well feature, creates the buffers, updates the data series and exports the map as a PDF. My issue is the report; it seems the only dynamic text I can use isn't data specific and the only data fields I can use only pertain to the feature the report utilizes (for me that's the address feature), I'd like to be able to change the title of each report to match the well and the buffer distance that report is referencing. I was hoping there'd be something similar to the listElements method used with the map layout object, but I wasn't able to find one and I'm not finding any other way to utilize dynamic texts or fields from another source.


Is there a way to update the static text in ArcGIS Pro's Report via Python?  

0 Kudos
2 Replies
New Contributor III

I found a solution! So, one attributes that can be added to the report is metadata and metadata can be modified with Python.  The attribute I decided to use was the Report Title feature within the Metadata.  So with the dynamic text added to my Report in the "Title Header" section, I am now able to update that text to whatever I needed it to be to more accurately reflect the contents of the report. 

New Contributor II

I have a similar problem.

I just updated my Pro install to 3.2.1 (the latest at this time).  One can create "Custom Report Templates (now in Pro 3.2!)," which I I want/need to use Python to iterate over some records in using a change to the Table's definition query and/or a search cursor to update what appears to me to be "Text Elements" that I could add to the Report Header.

None of the ESRI Report documentations seems to allow to access a list of Text Elements, let alone be able to change them.  This would be great to have.  If this functionality is currently available (ESRI, please reply and post the documentation), if not, then I will submit an Idea and hopefully, this will get "thumbed up!"

Glad you found a method to do this, but seems quirky for a fix.

I am attaching my ppkx file for my testing that includes many different reports and a few templates I am testing with.  I am not including my code at this time because I don't think ESRI has provided the functionality for listElements (and text elements) like they do with the map layout.

Anyone who looks at this, please refer to the Disabled Report Template with Group (a custom template) and the DISABLED_RPT_VW Report Test (which is the "report" derived from the custom template.

There seems no way to access the report past the primary Report Section and even this is limited.
The current online help doesn't seem to address these more specific items with the report layout or template.

These ESRI docs don't seem to provide enough information or indicates that the functionality I am looking for does not (yet) exist.  I hope this functionality comes along soon.  I am 95% where I need to be for my coding effort.

On a related note, if users could group and sort on multiple fields, this would be awesome and I would likely not have to write any code to perform the tweaks I am looking for in my report.  Previously, I have successfully used a "Table Frame," but since Pro 2.7, there seems to be a "bug" (in my opinion) where the definition query on the "table" in the table of contents does not update. through different iterations of my script using a search cursor.  I have performed copious testing on my code and I am leaning towards a "bug" when using Table Frames (which are a MAP_SURROUND in arcpy).  This is the reason I switched to Reports...they look promising up to the point, I cannot programmatically change "text elements" in the report 😞

Thank you!

0 Kudos