Select to view content in your preferred language

Data Driven Pages Thematic Map Book

5439
23
08-19-2014 12:46 PM
Status: Implemented
Labels (1)
MichaelGrieco
Occasional Contributor

 

Request:  Have Data Driven Pages actually produce a thematic map book.

 As discussed in the Esri Desktop help:

From the Ersi ArcGIS Help 10.2, 10.2.1, and 10.2.2

Thematic map book

A thematic map book is similar to a reference series, except that the detail pages show unique thematic maps of a single location.


The ability to display different unique themes (layers) covering a single location  would be invaluable to display the results of a multi phase analysis.  I have many clients that are tired of making a separate mxd for each theme.

 

 

Following is the clever solution supplied by Esri Support for my initial specific request:

 

 

import arcpy, os

 

mxd = arcpy.mapping.MapDocument(r"C; file location ")

mxdDDP = mxd.dataDrivenPages

 

for i in arcpy.mapping.ListLayers(mxd):

    if i in ["geology_geochem","glaciation","Precipitation Regime","geology_sed"]:

        i.visible = False

        arcpy.RefreshActiveView()

 

for i in range(mxdDDP.pageCount + 1):

    mxdDDP.currentPageID = i

    name = mxdDDP.pageRow.getValue(mxdDDP.pageNameField.name)

    print name

    if name == 'GEO':

        for i in arcpy.mapping.ListLayers(mxd):

            if i.name == "geology_geochem":

                i.visible = True

                arcpy.RefreshActiveView()

                mxdDDP.exportToPDF(r"C:\temp\GEO.pdf", "CURRENT")

                i.visible = False

                arcpy.RefreshActiveView()

    if name == 'GEO_sed':

        for i in arcpy.mapping.ListLayers(mxd):

            if i.name == "geology_sed":

                i.visible = True

                arcpy.RefreshActiveView()

                mxdDDP.exportToPDF(r"C:\temp\GEO_sed.pdf", "CURRENT")

                i.visible = False

                arcpy.RefreshActiveView()

    if name == 'GLA':

        for i in arcpy.mapping.ListLayers(mxd):

            if i.name == "glaciation":

                i.visible = True

                arcpy.RefreshActiveView()

                mxdDDP.exportToPDF(r"C:\temp\GLA.pdf", "CURRENT")

                i.visible = False

                arcpy.RefreshActiveView()

    if name == 'PRE':

        for i in arcpy.mapping.ListLayers(mxd):

            if i.name == "Precipitation Regime":

                i.visible = True

                arcpy.RefreshActiveView()

                mxdDDP.exportToPDF(r"C:\temp\PRE.pdf", "CURRENT")

                i.visible = False

                arcpy.RefreshActiveView()

 

 

 

This solution is just a go-by as my actual need is to display 40 different themes over the same extent.

 

23 Comments
AdamForknall

Data Driven Pages are great but they could be a whole lot better if a 'Layers' tab was added to the 'Set Up Data Driven Pages' dialogue which allowed configuration of layer visibility dependent on the page being displayed. The page would be selected by drop-down list, and layers turned on or off for that page via check boxes. Another check box could provide the ability top apply the layer display settings to all Data Driven Pages.
I guess something could be set up to do this based on fields in the layer attributes but that would probably be a bit too complicated for my liking.

0EM30000000Ctzu


Make sure you give this idea the thumbs up! 🙂
 

AdamForknall
This is kind of like having a page definition query, but heaps better because it's not dependant on attributes!
KirkHayer
This would be especial nice when using a differnt mask for page to highlight the data of interest.
CameronWallace
You can sort of fake it with the page definition query... 
If you're interested in a "Layer Driven Pages" tool that relies on layer attributes, I can upload the tool I built. It will turn on one layer at a time when cycling through a group layer (and each of those layers can be a group. To update text elements I built it to update a user-selected text element from each of the three layer attributes (name, description, credits). I typically use these fields to update: "Title, Notes, and Figure Number, respectively, but they can be set to anything.

I like the solution you propose, it's a bit more elegant. The version I built doesn't change location/extent... which would be nice to have as an option (although I'd probably end up using a page defintion for most of the applications at this point).
jcokin1
This request is long overdue ever since ESRI introduced Data Driven Pages in ArcGIS 10 (released on 06/30/2010).

As of right now, the only other way that this can be accomplished is with a 3rd party extension from MapLogic.

http://www.maplogic.com
0EME0000000UEkw


*Note to ESRI Moderator - Please add the "Petroleum" & "Natural Resources" tag to the idea as well.
PeterRussell
A nice option for this would be the ability to append all PDF's into one rather than having separate outputs
LauraBrent

I have used the MPS Atlas tool for years creating multiple maps (100's at a time) using one geographic extent, like the United States, but showing different data (like population, income, language preferences, country of origin) on each map.  I had the ability to create my map and place all the elements where they need to go, and then 'unlink' the maps so I could turn on/off the different features I would like to show, with all of the maps in one mxd.  Data Driven Pages doesn't allow for this capability.  To create the maps that I want to, using Data Driven Pages, I'll have to create hundreds of mxds, which is time/space consuming.

JeffBarrette

In ArcGIS Pro, we have it in our plans to build a thematic map series function as part of the application but in the meantime, it can really only be done using arcpy.mapping (in ArcMap) or arcpy.mp (in Pro).  I got this question several times at UC2019 and just recently got it again from a customer using ArcGIS Pro.  So below is a very simple example that demonstrates the basic arcpy.mp mechanics (similar to the code above, this same thing can be done in ArcMap with slight modification).  In both cases, you do need to modify the paths below.

I hope you find this useful,

Jeff

### This script is a very simple example of how to use arcpy.mp to create a
### thematic map series. The basic concept is to 1) control layer visibility
### between each export and 2) append the results into a single multi-page PDF.

### Understand there are many ways to manager layer visibility. One way is to
### have a series of group layers with a collection of layers you want displayed.
### A more advanced method is to manage a dictionary or text file that controls
### the layer visibility for each export.

### The example below is very basic. It first toggles off all layers
### except for the basemap. Next it creates a final PDF to store the pages.
### Next it toggles each layer on, exports to PDF, appends the results to the
### final PDF, and then removes the temporary file. It does this for each
### layer. At the very end, it uses the OS to open the final result.

import arcpy, os

#Reference Project, Layout, MapFrame, and Map
p = arcpy.mp.ArcGISProject(r"C:\Temp\GreatLakes\GreatLakes.aprx")
lyt = p.listLayouts('Layout')[0]
mf = lyt.listElements('MAPFRAME_ELEMENT', 'Map Frame')[0]
m = mf.map

#Turn off all layers in the map frame's map except the basemap
for lyr in m.listLayers():
if not lyr.isBasemapLayer:
lyr.visible = False

#Create final PDF (and remove if it already exists)
pdfPath = r"C:\Temp\GreatLakes\ThematicMapSeries.pdf"
if os.path.exists(pdfPath):
os.remove(pdfPath)
pdf = arcpy.mp.PDFDocumentCreate(pdfPath)

#Toggle each layer on, export, append the results, remove temp page
for lyr in m.listLayers():
if not lyr.isBasemapLayer:
print(lyr.name)
lyr.visible = True #toggle on
tempFile = os.path.join(r"C:\Temp", lyr.name + ".pdf")
lyt.exportToPDF(tempFile)
pdf.appendPages(tempFile)
os.remove(tempFile)
lyr.visible = False #toggle off (before next page)

#Commit the PDF and open
pdf.saveAndClose()
os.startfile(r"C:\Temp\GreatLakes\ThematicMapSeries.pdf")

MichaelMorgan4

It looks like the dropdown menu for the Map Series tab in Layout Properties in Arc Pro is just dying for a Thematic option, just to keep Spatial company.

JeffBarrette

Hi Michael,

At 2.6 we will be introducing a Bookmark Map Series option.  This will allow you to set the extents for each 'page' in the map series to a bookmark extent.  Thematic map books are something we are strongly considering for a future release but for now arcpy.mp is really the only way to control the precise logic needed to generate each unique page in the series.

Jeff

Esri Layout and arcpy.mp teams.