Recently, I had the need for a python script that would export a series of maps to PDF.
I wanted to set up a task using Python and Task Scheduler, that would access a workspace location and export every .mxd at that location to PDF at a specific time during the evening.
I began with a script I found here: http://support.esri.com/en/technical-article/000012420
I ended up with a slightly modified script, as shown below:
_________________________________________________________
#Import modules here
import arcpy, os
print ('Hello, finding workspace now...')
#Set workspace location here
arcpy.env.workspace = ws = r"C:\Test"
print ('Finding .mxd files now...')
#Create list of .mxd files within the workspace.
mxd_list = arcpy.ListFiles("*.mxd")
print ('Exporting to PDF now...')
for mxd in mxd_list:
current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd))
pdf_name = mxd[:-4] + ".pdf"
arcpy.mapping.ExportToPDF(current_mxd, pdf_name)
print ('Complete, thank you for using Map Exporter!')
__________________________________________________________
Next, I needed to set the script to run at a specific time.
To accomplish this, I started by opening Task Scheduler from the Windows Start Menu.
Next, I ran through the following steps:
1. Create a Basic Task
2. Start Daily
3. Run time 10 p.m., recurring daily
4. Action = Start a program
5. Select location of script
Now, I have a nice, tidy, fairly simple map exporter that will run every night at 10 p.m.
Additional information on utilizing the Task Scheduler is here: https://blogs.esri.com/esri/arcgis/2013/07/30/scheduling-a-scrip/
Subscribe to:
Post Comments (Atom)
Work in Progress - Disputed Areas Map
I started this project as a fun change of pace from my normal GIS day-to-day, and as a way of brushing up on my cartography skills. For me,...
-
Since 2013, I have been contributing to various projects with the Humanitarian OpenStreetMap Team ( http://tasks.hotosm.org/ ). While my co...
-
Recently I've been looking into alternative mapping tools, and wanted to give Google MyMaps a try. Despite a number of limitations (kml...
-
This has been something I've been meaning to write a post about for a while, and I finally found myself with a free moment to document t...
No comments:
Post a Comment