Select to view content in your preferred language

Can a Python script change map title to value from selected field?

4717
1
01-23-2012 11:42 AM
DrewSteffens1
Deactivated User
I have a relatively simple procedure that I want to accomplish using python.  I am automating production of a standard series of maps showing the same location but different data.  When writing a script to produce a USGS quad map of a property location, I would like the map title to change depending on the grid that the property falls within.  My logic here has been to perform a select by location and use the selected "Name" attribute to become the map title.  Can a selected attribute become a text element?

So far, I have written the selection criteria but I do not know where to go from here.

arcpy.SelectLayerByLocation_management("Quad\USGS Quad Boundaries","CONTAINS","lyrFile5","","NEW_SELECTION")


This procedure seems so simple but I have not been able to find a solution. Any help or insight on this matter is appreciated.
Tags (2)
0 Kudos
1 Reply
RaphaelR
Deactivated User
Hi Drew,

the second example from this blog entry could be useful to you:
http://blogs.esri.com/dev/blogs/arcgisdesktop/archive/2010/12/14/combining-data-driven-pages-with-py...

as for changing the text of the title, you have to specify the title element and access/change its text property:
for example:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")

# your title has to have "title" in the element name box (right-click on it \properties\size and position)
titleItem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "title")[0] 

# change the title´s text
titleItem.text = "some new title" 

0 Kudos