Select to view content in your preferred language

Data-Driven Pages: Dynamic Layout Element

7691
15
07-22-2010 10:52 AM
NoahBullock1
New Contributor
I'm using data driven pages to build a map book for the 50 states (i.e., my index layer). The layout of each page is identical except that on each state's page, I want an image of that state's seal. The images are all identical in size and format, they are stored in a directory, and I've appended their paths to the index layer attribute table. There doesn't appear to be a way to get them to dynamically display by using the data-driven page tools.

Anyone have any ideas on how to do this, either in combination with the ArcPy module, or by some other method?

Thanks,

Noah
0 Kudos
15 Replies
JuanRoubaud
New Contributor
How would you modify the script to include 2 different images?

I got the code below to work but now I need to modify it so I can insert 2 and up to 3 different images in the data frame

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Photo.mxd")
elm = arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT", "photo1")[0]
elmX = elm.elementPositionX; elmY = elm.elementPositionY
elmHeight = elm.elementHeight; elmWidth = elm.elementWidth

for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  imageName = mxd.dataDrivenPages.pageRow.getValue("image4map")
  elm.sourceImage = "C:\\Temp\\" + imageName
  elm.elementPositionX = elmX; elm.elementPositionY = elmY
  elm.elementHeight = elmHeight; elm.elementWidth = elmWidth
  print "Exporting Page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
  arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + str(pageNum) + ".pdf")
del mxd

Any help will be greatly appreciated.

Cheers,

J
0 Kudos
JeffBarrette
Esri Regular Contributor
You can't "insert" pictures into a layout.  You must first author the MXD with the appropriate number of picture elements and then move them on/off the page based on the particular page.  For example:

photo1 = arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT", "photo1")[0]
photo3 = arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT", "photo2")[0]
photo2 = arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT", "photo3")[0]

photo1.elementPositionX = 12  #Off the page
photo2.elementPositionX = 12  #Off the page
photo3.elementPositionX = 12  #Off the page

if page == 1: #Only 1 picture
  photo1.sourceImage = somePath
  photo1.elementPositionX = 1
  photo1.elementPositionY = 5
  photo1.elementHeight = 3
  photo1.elementWidth = 2
if page == 2: #Two pictures
  photo1.sourceImage = somePath
  photo1.elementPositionX = 4
  photo1.elementPositionY = 6
  photo1.elementHeight = 4
  photo1.elementWidth = 3
  photo2.sourceImage = somePath
  photo2.elementPositionX = 4
  photo2.elementPositionY = 6
  photo2.elementHeight = 4
  photo2.elementWidth = 3

etc


When I deal with these dynamic situations I like to store the properties in a table.  I read the table and set the value.

I hope this is helpful,
Jeff
0 Kudos
BrookeO_Neill
New Contributor II
I found a way to do this without writing a script.  I created a raster catalog and loaded the photographs I wanted to show for each page.  Then, I added a field to the raster catalog table and populated it with the data driven page numbers.  Then I turned on the page definition query function for the raster catalog and placed the raster catalog in a separate data frame on my layout.  This works best when all of your pictures are the same size and shape.
RichardMaher
New Contributor
I found a way to do this without writing a script.


Brooke, I would really appreciate the opportunity to message or e-mail you on this item. I am a land surveyor, with only a tutorial based knowledge of GIS, and have apparently (reading this subject in the forum) set myself up for a little of a challenge with one of my first projects!

Before I realized the question had been asked and answered in several forms I posted: http://forums.arcgis.com/threads/55233-Data-Driven-Page-With-Dynamic-Image?highlight=images+data+dri...

The answers are well beyond my current ability, but I took hope when I read your response. If I don't find a reasonable way to complete the need I'll have to drop back to Access (exporting the one map view I need perhaps). Maybe my request is simple enough I can hire someone for some coding to finish the final image element in my data driven pages.

I look forward to hearing from you if you are available. You can message me through the forum or at rich.maher "at" gmail.com

Thanks,

Rich
0 Kudos
deleted-user-st4HsVxccxgs
New Contributor III
I agree with Brooke. Using a Raster Catalog with images, then using enabling the page definition query for that layer to tell it what images to use on specific pages is the way to go. This basically opens up all kinds of possiblilities to easily display any data (by converting it to a jpeg or other image, then loading it to the raster catalog) on any page.
0 Kudos
WadeLobb
Occasional Contributor
With 10.1 you can now easily do dynamic photos with data driven pages

http://resources.arcgis.com/en/help/main/10.1/index.html#//00s900000022000000

If you are using Data Driven Pages you can make your picture element dynamic and have it update for each page. To do this, double-click the picture and go to the Picture tab. There are two options from which you can choose from: Simple path from Data Driven Pages and Attachment from Data Driven Pages.