ArcGIS Data Driven Pages – How to Change Scale Bar Interval and Settings

arcgis-desktopdata-driven-pagesscalescale bar

Sometimes I'll have a MXD set up as a mapbook using Data Driven Pages, but I'd like to display certain pages at a different scale than others in the same mapbook. I can do that using the Data Driven Scale option in Data Driven Pages, but when those pages are viewed or rendered, the scale bar uses the same units and divisions (for example, two 1000-foot sections) for all pages and is simply stretched or compressed to correctly match the display scale of each page. So if I have a mapbook where most pages are 1:12000, and one page is 1:6000, that one page will have a scale bar that is twice as long as the other pages, because ArcGIS is using the same settings (division units, division value) for the scale bar on every page.

Is there a way to change this, so that I can set the scale bar parameters independently for each page?

For example, if I go from a scale of 1:24000 to 1:10000, I might want to use increments of 0.25 miles and 500 feet respectively.

Currently what I'll do if I have, let's say, an 80-page mapbook with a few pages at a different scale than the rest, I'll render the majority of the pages first, then change the scale bar settings manually for the few pages that would look better with a different scale bar. But if someone comes along and opens the MXD after me and tries to render the same mapbook, they may not take that step and the scale bars will not be right.

Best Answer

I don't think you can change the properties of the scale bar using the out-of-the-box Data Driven Pages functionality.

However, that is not to say that what you're looking to do is impossible.

It wouldn't be terribly difficult to do this using ArcPy and is roughly described in this [ESRI Help Page][1]. Using their example, you could set up multiple scale bars, one for each setting you prefer, and then move them on and off the page based on scale of a given data-driven page.

To get it to work you would have to bypass the normal data-driven pages export and loop through the pages using Python and the above example.

Something along these lines (I HAVE NOT TESTED THIS, YOU WILL HAVE TO ADAPT IT TO YOUR DOCUMENT):

#You're going to need to reference your current map document and the data frame, assuming you just have one 
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

#Associate scale bars in your layout with variables that arcpy can manipulate
m_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "m scale bar")[0]
km_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "km scale bar")[0]

#Iterate through all the pages, for each page, look at the scale, then adjust the scale bars to be on, or off, the page.
for page in range(1, mxd.dataDrivenPages.pageCount +1):

    #Check the scale and move the elements around to get the right scale bar on the page
    if df.scale < 25000:
        m_scale.elementPositionX = 5 #on the page
        km_scale.elementPostitionX = 15 #off the page

        #Export the current page to a pdf, using a specified path
        arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\Project1.pdf", df)
    else:
        m_scale.elementPositionX = 15 #off the page
        km_scale.elementPostitionX = 5 #on the page

        #Export the current page to a pdf, using a specified path
        arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\Project1.pdf", df)
    mxd.dataDrivenPages.refresh()
Related Question