import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\ParcelAtlas.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] rasLyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Basemap.lyr") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum arcpy.mapping.AddLayer(df, rasLyrFile, "BOTTOM") #You can use InsertLayer for more precise placement mxd.dataDrivenPages.exportToPDF(r"C:\Project\Output\Page" + str(pageNum) + ".pdf", "CURRENT") arcpy.mapping.RemoveLayer(df, rasLyrFile) del mxd
Unfortunately arcpy.mapping can't work with the stretched renderer. Rather than the raster being a permanent layer in the MXD, what if you tried adding and deleting it with each page? Below is a sample snippet of code from the arcpy.mapping DDP Class help topic that I modified to add/remove your raster between DDP pages. It just requires that you save your raster out as a layer file. import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\ParcelAtlas.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] rasLyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Basemap.lyr") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum arcpy.mapping.AddLayer(df, rasLyrFile, "BOTTOM") #You can use InsertLayer for more precise placement mxd.dataDrivenPages.exportToPDF(r"C:\Project\Output\Page" + str(pageNum) + ".pdf", "CURRENT") arcpy.mapping.RemoveLayer(df, rasLyrFile) del mxdJeff
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.