AnsweredAssumed Answered

Automating Clip Output to Graphics Extent with arcpy

Question asked by allisonb on Nov 9, 2017
Latest reply on Aug 13, 2018 by jbrengel

I have a set of mxds that I would like to automate the process of printing to a PNG.  These files will be incorporated into other documents, so I need to remove the whitespace around the edge of the layout.  I can do this from the ArcMap interface using "Clip Output to Graphics Extent.", but there is no parameter in the ExportToPNG function to replicate this process in arcpy.mapping.    See:  arcpy function to Clip Output to Graphics Extent 

 

Similar questions have been posed on this board, 

Clip Output to Graphics Extent with arcpy 

Arcpy.mapping Get the extent of the map elements. 

but I need a little more clarification about how to actual automate the process with the version of Python and associated libraries that are installed with ArcMap (if that is, in fact, possible). 

 

I can get the max/min extent of the layout elements, (in page units) using arcpy.mapping.ListLayoutElements(), but I'm not sure how I can then use those values within the script to constrain the output image extent.  Is this possible?  Or do I need to use an external graphics library as mentioned by Gerry Gabrisch?  

 

The use of Data Driven Pages functionality was mentioned, but the specifics of this approach are not clear to me, since I have not used them before.   At first glance seems like a bit of a cumbersome approach for a simple need to get rid of white space around the edge of the page, but I'm open to using it if it's possible to automate the whole process.   

 

My layouts are often made up of several data frames as well as some individual graphic and text elements, so I'm not sure if that has any implications for use of the DDP approach.   In addition, the mxds that I would like to print, are not necessarily related to each other, I just want to be able to batch export a set of maps.

 

Thanks for any code snippets, tips, or ideas.   

 

Cross-referencing to mapping group: Mapping 

Outcomes