Data Driven Pages Thematic Map Book

798
15
08-19-2014 12:46 PM
Status: Under Consideration
Labels (1)
MichaelGrieco
New Contributor II

 

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.

 

15 Comments
JamesCokinos
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
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.

MarcelSt-Germain

Hope this thematic map thing will allow multiple layout each one  pointing to a specific page.  For now it's time consuming to do so with map series.

KoryKramer

Adding a link here to the Thematic Map Series samples just shared for ArcGIS Pro http://www.arcgis.com/home/item.html?id=eba53351ceb84b58b505dec5272e526c 

MarcelSt-Germain

Nice but still waiting for useful cartographic map series to make map.  I think, Esri doesn't understand the needs.

KoryKramer

Hi Marcel,

Did you look at the Readme provided with the download?  From the first paragraph of the Background, I think it is clear that the team does understand the needs, and was just touching on the surface of some of the complexities that will need to be addressed in order to design a user interface for this. 

Background

A thematic map series is when the extent of the map doesn’t change but the layers displayed modified for each page in the map series.  An example might be a residential site location where you want to display parcel information on one page, then fire districts, school districts, flood zone information, an so on, all on different pages.  A thematic map series currently can’t be created in the ArcGIS Pro interface, but it can be done using Python map automation.  A thematic map series can be more complex than just turning layers on and off before exporting a page and that is why a solution in the application interface isn’t available.  In many cases, depending on the thematic page, layers may need to be displayed in a different order, or display different symbology, definition queries, and different scale thresholds might be applied to a layer as well.  The layer specific logic can be automated in a Python script more easily than an application user interface that may not always satisfy all requirements.  Esri hopes to build a basic user interface for thematic maps but there may always be a need to further customize it with Python.

That aside, the team created this recent sample in an effort to be helpful.  I shared it on this thread with the same motivation.  We hope that users seeking this functionality will be aided by the provided samples.

Thank you!

MarcelSt-Germain

Maybe I'm not on the right path.  Effectively, it's like I'm mistaken the thematic map functions.

For me, at least, I think the problem still there.  No way to make maps like we need.  Call it map series, datadriven pages or so, still no function to do it the way it should be to make maps.  In a project we can have hundred layouts with one or more maps on each. 

You can created annotations link to pages. Very nice feature introduces years ago to clean up annotation in adjacent pages.  The problem that ESRI has not taken in context is that the datadriven pages or map series is for pages only, or I miss something.  

I know ESRI have thought of datadriven or map series for one layout to many extent of one map only.  What we need is very simple.  

In a map workflow you can have more than one map in a page.  Each one with his one name (ie map 1, map2, map 2-A etc on the page one).  So, you can't make the layout on page 1 that is not the same on page 2 or 3 or...  

What we need is a map series were in opening the page of a layout the map series of each of the map inside is activated.  And so on for each of the layout with one or more map on it.  For now, only one map is allowed (map series) by pages and when you change layout, pro do not remember (arcmap does) the update the mapseries.