DDP export to rasters with page names?

2120
5
Jump to solution
07-20-2012 12:14 PM
JohnSobetzer
Frequent Contributor
I have been using an arcpy script to export a view to a georeferenced tif, but the tifs come out as XXX1.tif, XXX2.tif, etc. where XXX is whatever text I put in the path and the number is the pageNum from the index file.  I'm probably missing something incredibly obvious but I can't find a way to have the output tifs include their individual DDP page names as happens with the standard export to pdf in a DDP.  Any suggestions?

If it makes it any easier here is the entire script which produces a series of tifs (and tfws) starting with currentName1.tif and ending at currentName19 in one particular case.

import arcpy
... mxd = arcpy.mapping.MapDocument("Current")
... df = arcpy.mapping.ListDataFrames(mxd)[0]
... ar = df.extent.height / df.extent.width
... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
...     mxd.dataDrivenPages.currentPageID = pageNum
...     print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
...     arcpy.mapping.ExportToTIFF(mxd,r"C:\Project\currentName" + str(pageNum) + ".tif",df,9306,9306*ar,300,True)
... del mxd
0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor
Have you tried something like:

>>>  mxd = arcpy.mapping.MapDocument("Current") ddp = mxd.dataDrivenPages df = arcpy.mapping.ListDataFrames(mxd)[0] for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):     mxd.dataDrivenPages.currentPageID = pageNum     arcpy.mapping.ExportToTIFF(mxd,r"C:\Temp\\" + str(ddp.pageRow.Name) + ".tif", df)


Where the "Name" pageRow.Name is the name of the field in the index layer.

Jeff

View solution in original post

0 Kudos
5 Replies
JeffBarrette
Esri Regular Contributor
Have you tried something like:

>>>  mxd = arcpy.mapping.MapDocument("Current") ddp = mxd.dataDrivenPages df = arcpy.mapping.ListDataFrames(mxd)[0] for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):     mxd.dataDrivenPages.currentPageID = pageNum     arcpy.mapping.ExportToTIFF(mxd,r"C:\Temp\\" + str(ddp.pageRow.Name) + ".tif", df)


Where the "Name" pageRow.Name is the name of the field in the index layer.

Jeff
0 Kudos
JohnSobetzer
Frequent Contributor
Thank you very much Jeff.  It's just what I needed.

I figured it had to be simple but I don't know python beyond mixing samples I can find. This one stumped me and I found a workaround right after posting so I let it go.  The workaround, however, is a clumsy one to set up (it uses a batch file renamer and a text file with input and output names) so this is so much better.

This is my current script to produce a properly georeferenced set of tifs from the same project I use for pdfs, showing a generic path of C:\Project for the output.

import arcpy
... mxd = arcpy.mapping.MapDocument("Current")
... ddp = mxd.dataDrivenPages
... df = arcpy.mapping.ListDataFrames(mxd)[0]
... ar = df.extent.height / df.extent.width
... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
...     mxd.dataDrivenPages.currentPageID = pageNum
...     print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
...     arcpy.mapping.ExportToTIFF(mxd,r"C:\Project\ctype12_" + str(ddp.pageRow.Name) + ".tif",df,9306,9306*ar,300,True)
... del mxd
0 Kudos
George_ChandeepCorea
New Contributor III
Thank you for this. It works perfectly and is exactly what I needed!
0 Kudos
ChristopherDean
New Contributor II
Have you tried something like:

>>> 
mxd = arcpy.mapping.MapDocument("Current")
ddp = mxd.dataDrivenPages
df = arcpy.mapping.ListDataFrames(mxd)[0]
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = pageNum
    arcpy.mapping.ExportToTIFF(mxd,r"C:\Temp\\" + str(ddp.pageRow.Name) + ".tif", df)


Where the "Name" pageRow.Name is the name of the field in the index layer.

Jeff


This works great for letting me name my files as I need to but it doesn't export the entire layout view of the mxd. Any idea what code is needed to export the layout view?

Thanks,
Chris
0 Kudos
ChristopherDean
New Contributor II
Found the answer in this thread:
http://forums.arcgis.com/threads/80836-exporting-layout-view-in-arcpy

replaced df with data_frame = "PAGE_LAYOUT"  and then df with data_frame and it exported the layout view correctly.

Thanks,
Chris
0 Kudos