Tag Archives: Map Book

New Resources Available for Getting started with Python Map Automation

ArcGIS 10 provides a new Python
mapping module (arcpy.mapping) that allows you to interact with the contents of
map documents and layer files without necessarily needing to interactively open an
ArcMap session.  The methods, properties and functions available in this
new map scripting API enable you, for example, to automate changing data
sources, modify layer properties, export and print maps, as well as automate the
creation of
thematic maps and map series.  Because the new mapping module is part of
the ArcPy geoprocessing framework, scripts can be used within ArcGIS Desktop
but can also be published to ArcGIS Server as geoprocessing services making
it much easier to make mapping and printing capabilities available on the
server.

The following links are resources
that will help you learn more about arcpy.mapping, get access to popular
sample scripts available for download, and
links to new training resources:

Help Resources

  • A new Introduction to
    arcpy.mapping
    help topic is a great starting point. It includes
    links to a new arcpy.mapping tutorial and general guidelines for working with
    arcpy.mapping. ArcGIS Desktop help has a complete section
    dedicated to the ArcPy mapping module. Embedded within the help topics
    are over 100 different, practical help samples that can be copied/pasted into your applications. Be
    sure to review the “Best ways to get started” section.

Sample Applications

  • Approximately 20
    script tools
    that perform routine map and layer management tasks, printing and
    exporting, as well as basic cartographic operations.
    This is an excellent download because it
    includes many practical code samples that perform a variety of tasks and they
    are easy enough to modify for your own purposes.
  • A script
    tool
    that combines Data Driven Pages, arcpy.mapping, and the ReportLab site package to generate a reference map book that includes street index
    pages. It demonstrates how arcpy.mapping can be used to extend Data
    Driven Pages capabilities.
  • A script
    that incorporates Data Driven Pages and arcpy.mapping to build a map series
    that includes dynamic graphic tables. There is a very complete README.doc file
    included with the download that also addresses other useful tips and tricks
    that go along with the application.

 Web Courses

  • Basics of Python (for ArcGIS 10).
    This course teaches fundamental concepts you need to know to create
    Python scripts in ArcGIS. You will learn guidelines for proper Python syntax,
    techniques to troubleshoot common errors, and how to use loops to test for
    conditions and execute different code based on the result.
  • Python Scripting for Map Automation in
    ArcGIS 10
    .
    This course teaches how to automate map production and
    related data management tasks that would be time-consuming and tedious to
    perform manually. You will learn how to work with the mapping module of the
    ArcPy site package to quickly and easily update map layers and map document
    properties, modify map content, and produce individual maps and map books.

 Special thanks to David from the Mapping Team for sharing these links.

Posted in Developer, Python | Tagged , , , , , , , , , , , , , , | Leave a comment

Creating Map Books using Data Driven Pages

A few weeks ago, thousands watched a live training seminar on the new Data Driven Pages in ArcGIS 10.  If you missed this excellent live seminar you can watch it on demand from Esri Training.

Description
Using the ArcGIS 10 Data Driven Pages feature, you can quickly and easily create a professional-quality map book from a single map document. This seminar teaches the workflow for using Data Driven Pages. The presenter also covers how to create an index layer from a feature layer and add dynamic text and locator maps to your map pages.

Who Should Attend
GIS professionals and cartographers working in utilities, transportation, public safety, and government mapping agencies and others who need to produce map books.

Key Points
The presenter discusses

  • Data Driven Pages, map books, index feature extents, and geoprocessing tools.
  • The process for building map books.
  • Updating, printing, and exporting map books.

 http://training.esri.com/gateway/index.cfm?fa=catalog.webCourseDetail&courseid=2152

Posted in Developer, Mapping, Python | Tagged , , , , , , , , , , , | 5 Comments

Migrating DSMapBooks to Data Driven Pages

Migrating your map books from the Map Book Developer Sample, DSMapBook, to data driven pages in ArcGIS 10 is a pretty straight forward process. It is not automatic, but many people have already done it and have found it to be quick and easy. The majority of the standard map book functionality is available in ArcGIS 10 without needing to write any Python scripts or having to dig into ArcObjects. How you do things with data driven pages is different, but the functionality for multiple pages, printing and exporting, creating index features, adding dynamic titles and text, creating locator maps, etc. is all there, out of the box.

It will depend on the complexity of your maps, but if you already have map documents and index layers, the basic process for migrating to data driven pages is not difficult. The workflow is as follows:

1)    Open the map document
2)    Open the data driven pages property page,
3)    Select the layer you used for your map extents as the index layer
4)    Update your dynamic text and titles using new dynamic text tags

If you have dynamic locator maps or custom page effects (like highlighting the current page), you can achieve these with some new data frame properties. The following blog post should help with this:
http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2010/02/02/Creating-dynamic-locator-maps-and-adding-page-effects-to-your-data-driven-pages.aspx

This gets more complex if you have customized the map book developer sample, or if you use the indexing functionality to generate a place name index, or a gazetteer. These require using some of the new arcpy.mapping Python scripting capabilities. If you have customized the developer sample in some way, first I would recommend reading about and trying the new functionality in ArcGIS 10 related to data driven pages. Some of the common customizations can be done out of the box now. If you are not able to accomplish what you need, the next step would be evaluating whether you can do it with using the new arcpy.mapping Python module that is available. We have included many sample scripts on the Resource Center to help you out including a sample for generating indexes

Supported map books, without the need for a developer sample should be a big benefit at ArcGIS 10. The migration process should be straight forward, and once it is done, it’s done. Spend some time reviewing the resources that are available and then give it a try with one of your map books. Here are some other resources that might be helpful to read before you start:

Blog post on creating map books with ArcGIS 10

Blog post on data driven pages

Desktop help on enabling data driven pages

Desktop help on working with dynamic text


Blog post on getting started with Python and map automation

Posted in Uncategorized | Tagged , , , , , , | 3 Comments

Combining Data Driven Pages with Python and arcpy.mapping

You can use arcpy.mapping, the Python module that allows you to interact with your map documents and layers, in conjunction with your data driven pages to do much more than make simple map books. For example, most complete map book products require title pages, overview maps, and sometimes pages of text or report information. In the past, putting these types of map books together could be time consuming, and usually required extra steps to assemble pages into a single document. At ArcGIS 10 putting together this type of map book product can be automated with a simple Python script.  

The following example exports a title page, an overview map, and a series of data driven pages and combines them, along with a PDF file containing a list of contact information, into a single multi-page PDF file:

import arcpy, os, string
#Create final output PDF file
finalPdf = arcpy.mapping.PDFDocumentCreate(r”C:MyProjectMyAtlas.pdf”)

#Export Title page and append to final PDF file
mxd = arcpy.mapping.MapDocument(r”C:MyProjectMyTitlePage.mxd”)
tmpPdf = r”C:MyProjectMyTitlePage.pdf”
arcpy.mapping.ExportToPDF(mxd, tmpPdf)
finalPdf.appendPages(tmpPdf)
del mxd, tmpPdf
    
#Export Overview Map and append to final PDF file    
mxd = arcpy.mapping.MapDocument(r”C:MyProjectMyOverviewMap.mxd”)
tmpPdf = r”C:MyProjectMyOverviewMap.pdf”
arcpy.mapping.ExportToPDF(mxd, tmpPdf)
finalPdf.appendPages(tmpPdf)
del mxd, tmpPdf

#Export Data Driven Pages and append to final PDF file    
mxd = arcpy.mapping.MapDocument(r”C:MyProjectMyAtlasPages.mxd”)
tmpPdf = r”C:MyProjectMyAtlasPages.pdf”
ddp = mxd.dataDrivenPages
ddp.exportToPDF(tmpPdf, “ALL”)
finalPdf.appendPages(tmpPdf)
del mxd, tmpPdf

#Append Contact Information to final PDF file
finalPdf.appendPages(r”C:MyProjectContactInfo.pdf”)

#Update the properties of the final pdf to show thumbnail view
finalPdf.updateDocProperties(pdf_open_view=”USE_THUMBS”,
                             pdf_layout=”SINGLE_PAGE”)

del finalPdf

You can also use python in conjunction with data driven pages to cycle through each page, and perform one of the many operations supported by arcpy.mapping. For example, you can update a layer’s symbology, update some layout text, and export or print each map. This example demonstrates how to cycle through all your data driven pages and export them as PNG files:
import arcpy

#Specify the map document
mxd = arcpy.mapping.MapDocument(r”C:MyProjectMyAtlasPages.mxd”)

#Export each of the data driven pages
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.ExportToPNG(mxd, r”C:MyProjectOutputMyAtlas_Page” + str(pageNum) + “.png”)
del mxd

See the following blog entry for more info on exporting and printing using arcpy.mapping: http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2010/02/01/ArcPy-and-Geoprocessing_2620_-it_1920_s-for-Developers-too.aspx

arcpy.mapping opens up many possibilities for the types of map books you can create. For example, you can create a thematic atlas with multiple pages specifying a different theme on each page. The following example zooms to a selected parcel, toggles on different layer visibility and exports the layout for multiple themes in order to create a parcel report with a soil map, a flood map and a zoning map:

import arcpy, os

#Specify output path and final output PDF
outPath = r”C:MyProjectoutput\”
finalPdf = arcpy.mapping.PDFDocumentCreate(outPath + “ParcelReport.pdf”)

#Specify the map document and the data frame
mxd = arcpy.mapping.MapDocument(r”C:MyProjectMyParcelMap.mxd”)
df = arcpy.mapping.ListDataFrames(mxd, “Layers”)[0]

#Select a parcel using the LocAddress attribute and zoom to selected
parcelLayer = arcpy.mapping.ListLayers(mxd, “Parcels”, df)[0]
arcpy.SelectLayerByAttribute_management(parcelLayer, “NEW_SELECTION”, “”LocAddress” = ’519 Main St’”)
df.zoomToSelectedFeatures()

#Turn on visibility for each theme and export the page
lyrList = ["Soils", "Floodplains", "Zones"]
for lyrName in lyrList:
     lyr = arcpy.mapping.ListLayers(mxd, lyrName, df)[0]
     lyr.visible = True

     #Export each theme to a temporary PDF and append to the final PDF
     tmpPdf = outPath + lyrName + “_temp.pdf”
     if os.path.exists(tmpPdf):
          os.remove(tmpPdf)
     arcpy.mapping.ExportToPDF(mxd, tmpPdf)
     finalPdf.appendPages(tmpPdf)
     
     #Turn off layer visibility and clean up for next pass through the loop
     lyr.visible = False
     del lyr, tmpPdf
del mxd, df, finalPdf

Frequently map books require a separate layout for a left and right page in order to create a wider margin in the middle when the pages are bound together. Or some map books require page layouts using different orientations, where some of the maps are portrait and some are landscape.   In this example we use two layouts, one for the left and one for the right. Both layouts have multiple pages created using data driven pages. The following script exports all the left pages and all the right pages and assembles them together into a single PDF file:

import arcpy, os

# Specify left and right map documents and create final output PDF file
mxdLeft = arcpy.mapping.MapDocument(r”C:MyProjectMyAtlas_left.mxd”)
mxdRight = arcpy.mapping.MapDocument(r”C:MyProjectMyAtlas_right.mxd”)
finalPdf = arcpy.mapping.PDFDocumentCreate(r”C:MyProjectMyAtlas.pdf”)

#Export left (odd) pages to temporary PDF files
for pgNumLeft in range(1, mxdLeft.dataDrivenPages.pageCount + 1, 2):
    mxdLeft.dataDrivenPages.currentPageID = pgNumLeft
    arcpy.mapping.ExportToPDF(mxdLeft, r”C:MyProjectTemp_Page” + str(pgNumLeft) + “.pdf”)

#Export right (even) pages to temporary PDF files
for pgNumRight in range(2, mxdRight.dataDrivenPages.pageCount + 1, 2):
    mxdRight.dataDrivenPages.currentPageID = pgNumRight
    arcpy.mapping.ExportToPDF(mxdRight, r”C:DataDemosHamiltonCoDemooutputAtlas_Page” + str(pgNumRight) + “.pdf”)

#Append all pages into final PDF file and clean up temporary PDF files
for pgNum in range(1, mxdLeft.dataDrivenPages.pageCount + 1,):
    tmpPdf = r”C:DataDemosHamiltonCoDemooutputAtlas_Page” + str(pgNum) + “.pdf”
    if os.path.exists(tmpPdf):
         finalPdf.appendPages (tmpPdf)
         os.remove(tmpPdf)
del mxdLeft, mxdRight, finalPdf, tmpPdf

When you combine the multiple pages, and dynamic layout elements from data driven pages along with the things you can do with arcpy.mapping there are many possibilities. Arcpy.mapping makes it easy to write powerful Python scripts that automate many of the redundant map book and atlas compilation and production tasks.

These are just a small sample.  There is a lot more you can do with arcpy.mapping.  See an overview at:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000032000000.htm

You can find additional sample scripts at Code Gallery

 

Posted in Uncategorized | Tagged , , , , , , , | 3 Comments

Creating Place Name Indexes for Map Books

ArcGIS 10 includes the ability to make multiple-page map books using data driven pages. However, map books are often a collection of information in addition to the maps, for example, title pages, tables of contents, and index pages.  So, in addition to data driven pages, ArcGIS 10 includes the arcpy.mapping Python module that provides the ability to create and combine a series of pages into a final map book product.  

Building an index or gazetteer of place names is a common requirement for map books, and data driven pages by themselves do not provide a solution for building the index pages. However, Python scripting can be used to create these. We have placed a sample on the Resource Center to help. The sample combines the use of Data Driven Pages, arcpy.mapping, and a 3rd party PDF design toolkit called ReportLab to create a final map book product with index pages.

 

Indexes can vary greatly from organization to organization. The rules for what is indexed, how the index table is compiled, and the index formats can differ widely.  This sample provides one example. However, both the geoprocessing workflow and script can be customized for your particular index needs (Note:  In the geoprocessing steps in this example the Frequency tool is used that requires an ArcInfo license.).  Also, one of the nice things about using ReportLab is it gives you all sorts of formatting options for the results.  The arcpy.mapping Map Book with Index Pages sample can be downloaded here.

Content provided by David W.

Posted in Uncategorized | Tagged , , , , , , , , | 1 Comment

Esri Press presents Map Book Vol. 23

By Charlie Frye, Esri Chief Cartographer

Colors in ArcGIS Symbols - Thumbnail

The Esri Map Book has become an annual must-have collectors item for Esri International User Conference attendees and GIS users alike. The twenty-third volume of the Esri Map Book showcases the innovative and inspiring accomplishments of GIS users around the world. The true excitement of this book lies in the discovery of which maps have made it from the 2007 Esri International User Conference Map Gallery into publication. More than 100 full-color maps are featured from distinct industry categories such as cartography, environmental management, government, natural resources, planning and engineering, tourism, transportation, and utilities. Each map is presented with an insightful description of how it was produced or used. The maps were hand selected by Jack Dangermond, the book edited by Michael Law, and designed by Doug Huibregtse.

Continue reading

Posted in Mapping | Tagged , , | 4 Comments