Select to view content in your preferred language

ArcPy: Data Driven Pages to Individual Map Packages

3118
4
Jump to solution
01-20-2016 07:38 AM
PeterWilson
Frequent Contributor

I came across the following sample code that Chris Fox from esri wrote as a way to create a new mxd for each Data Driven Page:

mxdPath = r"C:\Project\DDPMap.mxd"
mxd = arcpy.mapping.MapDocument(mxdPath)
mxdDir = os.path.dirname(mxdPath)
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = pageNum
    mxdName = os.path.join(mxdDir, "DDPMap", + str(pageNum) + ".mxd")
    mxd.saveACopy(mxdName)
del mxd

Is there  a way to create a map package for each Data Driven Page instead of having to save it out first as a new mxd.

arcpy package map sample:

for mxd in arcpy.ListFiles("*.mxd"):
    arcpy.AddMessage("Packaging: {}".format(mxd))
    arcpy.PackageMap_management(mxd, os.path.splittext(mxd) [0] + ".mpk", "PRESERVE", "CONVERT_ARCSDE", "DISPLAY", "ALL")
0 Kudos
1 Solution

Accepted Solutions
PeterWilson
Frequent Contributor

I've successfully created a python script that generates a map package for each data driven page. The only stumbling block that I still have is that the extent parameter for package map is based on the active data frame extent and not individually for each data frame. This is a shame as a lot of maps have a data frame that represents a inset of your study area. I'd like to clip my data to the extent of each data frame before creating a map package as to reduce the data being replicated for each map package.

I've attached my python script if anyone is interested.

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

given it wants a project Package Map—Help | ArcGIS for Desktop

as its primary input, I am not sure how you could circumvent that but there is lots of stuff in the package toolkit

An overview of the Package toolset—Help | ArcGIS for Desktop

but there is this quasi-related thread

Re: Export Data Driven Pages to MXD with file name by Page Name

PeterWilson
Frequent Contributor

I've successfully created a python script that generates a map package for each data driven page. The only stumbling block that I still have is that the extent parameter for package map is based on the active data frame extent and not individually for each data frame. This is a shame as a lot of maps have a data frame that represents a inset of your study area. I'd like to clip my data to the extent of each data frame before creating a map package as to reduce the data being replicated for each map package.

I've attached my python script if anyone is interested.

DanPatterson_Retired
MVP Emeritus

Thanks Peter

some info from... DataFrame—Help | ArcGIS for Desktop

The data frame extent coordinates are based on the extent of the data frame in Layout View, not in Data View. This is because the shape of the data frame in Data View may have a different aspect ratio than the data frame in Layout View.

So if this persists arcgis Pro may solve the problem... no more one layout...no more shifting and shuffling onto the layout page... kind of like the arcgis 3.x days

0 Kudos
DanPatterson_Retired
MVP Emeritus

Peter... related but not a solution but you may find it interesting http://www.arcgis.com/home/item.html?id=a9b032f739254ebeb6221c9294ebc886

0 Kudos