Clip Output to Graphics Extent with arcpy

5820
10
11-16-2010 05:41 PM
JaneWickers
New Contributor III
When exporting a map from layout in ArcMap there is an option to "Clip Output to Graphics Extent". Is it possible to automate this function with arcpy?

Jane
0 Kudos
10 Replies
JeffBarrette
Esri Regular Contributor
Jane,

This option is not available in with the arcpy.mapping Export functions.  I'd like to know more about how you use this and why.  I also recommend that you add this to the http://ideas.arcgis.com website.  It may be possible to add in a future release but we'd really like to know the use cases in terms of map automation.

Thanks,
Jeff
0 Kudos
JaneWickers
New Contributor III
Thanks Jeff. I am creating a tool where the user inputs a Property Number, Scale and Description. The mxd then zooms to that Property at the scale nominated and outputs to a pdf. The user who has requested this tool frequently uses the Clip Output to Graphics Extent to export to the pdf. She has asked me to incorporate this into my tool (using arcy).

Jane
0 Kudos
Kathleen_Crombez
Occasional Contributor III
I also need this functionality. We create a tax map book application on CD that has to be completely functional without access to the internet. The website has images that I export from ArcMap as a png that has corresponding rollover hotspots for the townships and the map book pages. For duplication purposes (we build this application for every revenue year), it is critical that the exported images are clipped to the graphics extent or the rollovers will not line up on the images. This is the only process holdng me up from running a python script to completely automate the process of building the application every year. I have to manually export nearly 40 images before i can run my script and the application gets built. I hope this functionality gets implimented in the next release.
0 Kudos
JeffBarrette
Esri Regular Contributor
As an alternative, why can't you just use a masking layer?  The masking layer can "white out" the zone outside the area of interest before the export is done. 

This can be done in the user interface with Data Driven Pages using page definitions (via the definition query tab).

Or it can be done with arcpy.mapping in a similar way but by automating the updating of definition queries.

Jeff
0 Kudos
KarlaMayne
New Contributor II
Hi Jeff,

I'm currently working on a script for exporting ddp with a mask layer and I'm having trouble getting the definition query to update for each page as it exports.  I'd appreciate it if you could take a look and provide suggestions.  Here's the script:

import arcpy, sys, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")

print "Enter save as pdf location:"
pdfDir = arcpy.GetParameterAsText(0)
outputFolder = pdfDir + r"\PDFs"

df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
maskLayer = arcpy.mapping.ListLayers(mxd, "state_bnd110", df)[0]
maskField = "STATE_NAME"

for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = pageNum
    pageName = mxd.dataDrivenPages.pageRow.STATE_NAME
    for lyr in arcpy.mapping.ListLayers(mxd):
        if lyr.name == maskLayer:
            lyr.definitionQuery = '"STATE_NAME" <> %s' % pageName
    arcpy.RefreshActiveView()
    arcpy.mapping.ExportToPDF(mxd, os.path.dirname(outputFolder)+ os.sep + pageName + ".pdf")

del mxd
arcpy.GetMessages()


Thanks,
Karla
0 Kudos
NilsBabel
Occasional Contributor II
I had the same issue.  I was using the clip output to graphics extent in the tool and wanted to automate the process.  I'm creating map graphics for reports and PPTs.  I use the clip graphics function because I don't want the extra white space around my graphic.  To get around this in Arcpy I resized my layout.  Under page and print layout I unchecked the use printer paper settings option.  Then I moved my dataframe and layout items to an origin of 0, 0 on the Size and Position properties tab.  This essentially eliminates the "margin" that is needed for printing to paper.  This works for me because I'm just exporting the maps to graphics.  The downside is if you want to print the mxd you'll likely lose the edge of your map because there is no longer a margin.  I guess if you do it this way you don't really need the clip output option in the Arcpy function but it still would be nice to have the option.
0 Kudos
MarcCusumano
Occasional Contributor
Can "Clip to Graphics Extent" be used in a python script utilizing the ArcPy.ExportCAD_conversion method? We are trying to export DXF tiles based on a grid layer and providing an extent makes a selection of features passing through, but does not clip the output to the proper extent, resulting in features running way outside the boundaries of each tile.
0 Kudos
ANilsen
New Contributor
Hi,
will "Clip Output to Graphics Extent" when exporting a map to pdf be included in arcpy in ver. 10.1?
And/or is it another way to clip to output extent before exporting to pdf through arcpy?
Best regards
Anne
0 Kudos
JeffBarrette
Esri Regular Contributor
This direct capability was not added at 10.1 but have you tried definition queries and page definitions (with DDP)?

Jeff
0 Kudos