Data Driven Pages - Reference Grid interval update with Scale?

2989
3
02-22-2012 06:01 AM
KarlWilson
Occasional Contributor III
Is it possible to automatically update the reference grid for data driven pages with different scales?

For example, If I have a map with a lat/long reference grid at 3° intervals set up in the Data Frame Properties, it will look OK at 1:3,000,000 scale. If one of the data driven pages I generate is a map at 1:250,000 scale, how can I ensure that the reference grid intervals change to something more approprite - e.g. 30' intervals?

Thanks,
Karl
0 Kudos
3 Replies
JeffBarrette
Esri Regular Contributor
These settings are not accessible from Data Driven Pages or the arcpy.mapping API.

One possible solution is to have an MXD for each appropriate scale.  You could have a DDP MXD for 1:3,000,000 and another for 1:250,000.  Simply select the index features for each scale and run your exports.

You may want to review the following link on the esri ideas page.  I think this is what you are asking for.
http://ideas.arcgis.com/ideaView?id=087300000008MmJAAU


Jeff
0 Kudos
KarlWilson
Occasional Contributor III
Thanks for the reply Jeff, I guess the Data Driven Pages aren't quite as automated as I'd like just yet.

I have promoted the idea and added my comments.
0 Kudos
KarlWilson
Occasional Contributor III
I have found two workarounds for this issue.

1. Create several MXD map documents. One for each set of maps that share a common scale, with the grids and graticules as desired.

  • Use ArcPy to export them all as individual PDF pages and collate them together in the right order.


2. Use one MXD map document with several data frames. The first data frame contains the data and DDP index layer. Subsequent data frames with no data, but with a grid/graticule.

  • The subsequent data frames are created exactly on top of the first data frame with the same page dimensions in the layout view. The extent is set to be derived from the first data frame, and the name includes the scale that they are suitable for. Once checked that these grid/graticule data frames look OK, offset them by a set amount (say -40cm in the X plane) so they don't appear in the layout view and slow ArcMap down.

  • Then use an ArcPY script to cycle through the DDP. For each page, check the scale (taken from a scale attribute in the DDP index layer) against the data frame name. When a scale matches a grid/graticule data frame, move it directly over the map, export the pdf page, and then move it back again.



Here is a copy of my current code for the second method, designed to be used with a script tool. A lot of parts are still hard-coded, so I'm sure it could be improved.

# Import arcpy module
import arcpy

# Read the parameter values:
#  1: Input MXD
#  2: Output folder
#  3. Output filename

mxdPath = arcpy.GetParameterAsText(0)
outDir = arcpy.GetParameterAsText(1)
outFile = arcpy.GetParameterAsText(2)

arcpy.AddMessage("Processing: "+mxdPath)
mxd = arcpy.mapping.MapDocument(mxdPath)

# Get data frames from mxd
dfs = arcpy.mapping.ListDataFrames(mxd)

# Assume first data frame is the map (HARDCODED) and get the x page offset
x = dfs[0].elementPositionX

#Create final output PDF file
finalPdf = arcpy.mapping.PDFDocumentCreate(outDir + "\\" + outFile + ".pdf")

# Cycle through DDP in mxd
pageCount = mxd.dataDrivenPages.pageCount
for pageNum in range(1, pageCount + 1):
    mxd.dataDrivenPages.currentPageID = pageNum
    # Get scale from DDP index layer (HARDCODED - assumes "Scale" attribute exists)
    scale = mxd.dataDrivenPages.pageRow.Scale
    # Move Grids & Graticules in position for each scale (HARDCODED - data frames must have certain names)
    for df in dfs:
        if (df.name == "Graticule_"+str(scale)) or (df.name == "Grid_"+str(scale)):
            df.elementPositionX = x  
    arcpy.AddMessage("Exporting page {0} of {1}".format(str(pageNum), str(pageCount)))
    tmpPdf = outDir + "\\" + "temp.pdf"
    arcpy.mapping.ExportToPDF(mxd, tmpPdf)
    finalPdf.appendPages(tmpPdf)
    # Move Grids & Graticules back to original position (HARDCODED -40cm assumed)
    for df in dfs:
        if (df.name == "Graticule_"+str(scale)) or (df.name == "Grid_"+str(scale)):
            df.elementPositionX = -40           
    del tmpPdf
    
arcpy.AddMessage("Saving: " + outFile + ".pdf")

finalPdf.saveAndClose()


Karl
0 Kudos