Export multiple raster into single pdf, using ArcPy?

2183
10
Jump to solution
08-31-2016 10:04 PM
ShouvikJha
Occasional Contributor III

I have 12 rasters for different month in single folder (Name of raster r001_npp, r002_npp…..012_npp). I am trying to export those raster into single pdf file along with layout, north arrow, scale bar, and legend and I want to keep one legend for all rasters. 

Below I have attached the sample raster file and images for reference, which I trying to do.

Any guidance to automate the process would be great.

Example of output pdf here 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor
10 Replies
DanPatterson_Retired
MVP Esteemed Contributor

With the arcpy mapping module... Introduction to arcpy.mapping—Help | ArcGIS for Desktop 

ShouvikJha
Occasional Contributor III

Dan_Patterson‌. Thank you very much. I gone through the page suggested by you. Really it is very useful. I have one doubt that, I have 12 rasters, so i have to create 12 mxd file for each raster or only one mxd file for all raster to generate the output as same which i posted with my question.  

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Perhaps this topic will help you make up your mind

ExportToPDF—Help | ArcGIS for Desktop 

there are also tutorials, help docs and example on the Code sharing site, I did a search using 'arcpy mapping' as a phrase search

ArcGIS Code Sharing have a look

ShouvikJha
Occasional Contributor III

I have visited many pages but still confused. how do i process it, even i am not getting such reference that  Arc GIS allow or not such plot. 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

What do you have as a script so far? Do you have a working script that produces 1 pdf? There are options on the Code Sharing site to combin pdf files which might be an easier option for you if you already have partitioned into 12 mxd's

ShouvikJha
Occasional Contributor III

Dan Patterson‌, Thank you. I have few question, Hopefully this time i can clear my doubt,

1. I have 12 raster file, my aim is to plot all those raster into single pdf file using single legend, so i have to create 12 mxd for different raster or i have to create only 1 mxd for all raster? (In one mxd file, multi data frame can be added, its like draw a frame inside the frame , below i have attached one ArcGIS's snapshot of multilayer framing ). 

Below is my working code that can produce pdf file from one mxd, 

import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0] 
arcpy.mapping.ExportToPDF(mxd, r"C:\Project\Output\ProjectDataFrame.pdf", df, df_export_width=1600, df_export_height=1200) 
del mxd‍‍‍‍

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

It sounds like you are trying to go through the tutorial, but with the maps combined onto a page.  For working with one map document, data driven pages is one option, but I don't know if it covers what you want

0 Kudos
ShouvikJha
Occasional Contributor III

Thank you. I am trying to do it. I am also not sure Multi-plot facility in Arc GIS has or not. I am taking suggestion from other developer also. Hopefully problem would be be resolve.

Which snapshot i have attached, there i have added 3 data frame for reference purpose only. similarly i want to add total 12 raster into one frame and export it to pdf format.

0 Kudos
XanderBakker
Esri Esteemed Contributor

You can also export each pdf separately and combine them in a single output PDF:

# output PDF to create
pdf_file_out = r'C:\Path\To\My\Output\PDF\File\myOuputPDF.pdf'

# list of PDF files (separate exports)
myListofPDFfiles = [r'C:\Path\To\My\Input\PDF\File\myPDF01.pdf',
                    r'C:\Path\To\My\Input\PDF\File\myPDF02.pdf',
                    r'C:\Path\To\My\Input\PDF\File\myPDF03.pdf']

# create output PDF
pdf_doc = arcpy.mapping.PDFDocumentCreate(pdf_file_out)

# add inividual input PDF files
for pdf_file_in in myListofPDFfiles:
    pdf_doc.appendPages(pdf_file_in)

# save and close
pdf_doc.saveAndClose()
del pdf_doc