<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Can a Python script change map title to value from selected field? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-a-python-script-change-map-title-to-value-from/m-p/87466#M6847</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a relatively simple procedure that I want to accomplish using python.&amp;nbsp; I am automating production of a standard series of maps showing the same location but different data.&amp;nbsp; 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.&amp;nbsp; My logic here has been to perform a select by location and use the selected "Name" attribute to become the map title.&amp;nbsp; Can a selected attribute become a text element?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far, I have written the selection criteria but I do not know where to go from here. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management("Quad\USGS Quad Boundaries","CONTAINS","lyrFile5","","NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This procedure seems so simple but I have not been able to find a solution. Any help or insight on this matter is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jan 2012 19:42:15 GMT</pubDate>
    <dc:creator>DrewSteffens1</dc:creator>
    <dc:date>2012-01-23T19:42:15Z</dc:date>
    <item>
      <title>Can a Python script change map title to value from selected field?</title>
      <link>https://community.esri.com/t5/python-questions/can-a-python-script-change-map-title-to-value-from/m-p/87466#M6847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a relatively simple procedure that I want to accomplish using python.&amp;nbsp; I am automating production of a standard series of maps showing the same location but different data.&amp;nbsp; 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.&amp;nbsp; My logic here has been to perform a select by location and use the selected "Name" attribute to become the map title.&amp;nbsp; Can a selected attribute become a text element?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far, I have written the selection criteria but I do not know where to go from here. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByLocation_management("Quad\USGS Quad Boundaries","CONTAINS","lyrFile5","","NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This procedure seems so simple but I have not been able to find a solution. Any help or insight on this matter is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jan 2012 19:42:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-a-python-script-change-map-title-to-value-from/m-p/87466#M6847</guid>
      <dc:creator>DrewSteffens1</dc:creator>
      <dc:date>2012-01-23T19:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can a Python script change map title to value from selected field?</title>
      <link>https://community.esri.com/t5/python-questions/can-a-python-script-change-map-title-to-value-from/m-p/87467#M6848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Drew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the second example from this blog entry could be useful to you:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://blogs.esri.com/dev/blogs/arcgisdesktop/archive/2010/12/14/combining-data-driven-pages-with-python-and-arcpy.mapping.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://blogs.esri.com/dev/blogs/arcgisdesktop/archive/2010/12/14/combining-data-driven-pages-with-python-and-arcpy.mapping.aspx&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;as for changing the text of the title, you have to specify the title element and access/change its text property:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
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" 

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:20:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-a-python-script-change-map-title-to-value-from/m-p/87467#M6848</guid>
      <dc:creator>RaphaelR</dc:creator>
      <dc:date>2021-12-10T23:20:57Z</dc:date>
    </item>
  </channel>
</rss>

