1

I was wondering if there was a way to put a title and integer data from an attribute table in a new layer created in Python. I was able to create a new layer using copy features, zoom to the selected features, and export the zoomed features in a map as a PNG all using arcpy, but I also wanted a title at the top and data from the attribute table of that specific layer in the map layout before it was exported. Is it possible to get all this automated using Python?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Dec 12, 2013 at 19:42

1 Answer 1

2

Yes, just do a search cursor to get the specific field/record value and update layout default title text (you set this within a template map document), see sample code below.

import arcpy
# run search cursor here
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
 if elm.text == "default title text":
 elm.text = myFieldValue # variable grabed from search cursor
mxd.save()
del mxd

If you want to export the map layout to png you may use ExportToPNG

answered Dec 12, 2013 at 20:11
2
  • Would I be able to do this from a new layer in the same arcpy process? I created a new feature layer and I wanted that layer to be edited with title and density data from the attribute table and then exported to PNG all within the same script. Is that possible with the search cursor? Commented Dec 12, 2013 at 20:50
  • @Victor, Yes it should be possible. If you post your script within your question I may be able to further assist. Commented Dec 13, 2013 at 13:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.