I have made an ArcPy add-in that assists a user by adding layers from a nominated fGDB to their map based on a nominated extent. I wish to add a button that changes the data frame properties to clip all the TOC layers to shape (the extent polygon). I can't find an ArcGIS Desktop function to do this. There is however a production mapping (PLTS Extension) function that might suit, but we don't wish to purchase a "solution" for a 9 click standard desktop process.

ArPyProduction Clip To Data-frame: http://resources.arcgis.com/en/help/main/10.1/index.html#//010300000306000000

Any ideas?

class ButtonClass3(object):
    """Implementation for Version1_Addin_addin.button_1 (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
    print "Limiting display of layers to your extent"

    mxd = arcpy.mapping.MapDocument('current')
    df = mxd.activeDataFrame
    global ExtentFC
    ExtentFC = "C:\\Data\\ArcGIS\\SelectData.gdb\\ExtentFC" 
    global ExtentFCLayer
    ExtentFCLayer ="Current_Extent"
    global ExtentLyrPath
    ExtentLyrPath = "C:\\Data\\ArcGIS\\ExtentLayerFile.lyr"

    ### Carto
    arcpy.MakeFeatureLayer_management(ExtentFC, ExtentFCLayer"", "", "")
    FeatureClassLayerMapping = arcpy.mapping.Layer(ExtentFCLayer)
    ExtentLyr = arcpy.mapping.Layer(ExtentLyrPath)
    arcpy.mapping.UpdateLayer(df, FeatureClassLayerMapping, ExtentLyr, True)

    ### Select Extent & Zoom
    arcpy.SelectLayerByAttribute_management(ExtentFCLayer,"NEW_SELECTION","\"OBJECTID\" >0 ")

    ### arcpyproduction EXAMPLE A:
    arcpyproduction.mapping.ClipDataFrameToGeometry (data_frame, clip_geometry, {exclusion_layers})

    ### arcpyproduction EXAMPLE B:
    arcpyproduction.mapping.ClipDataFrameToGeometry (df, ExtentFCLayer, [0])

    del ExtentFC, ExtentFCLayer, ExtentLyr
  • 1
    To do this I think your code will need to use the current data frame extent to create a rectangular polygon geometry, and then use the clipping features to erase the extent geometry with them (or use Union and Select if you are not licensed for Erase). Add that extent polygon (with hole for features) to the top of your TOC so it hides everything except the hole. Fire this code each time your extent changes. It's not trivial but should be quite doable and a nice python add-in example.
    – PolyGeo
    Apr 30, 2014 at 9:21
  • PolyGeo, I love the way you think. A global polygon cookie cut to the current extent is a great work around for the cartography (once it's updated to be solid white). My only concern (in my case) is the million of features drawing before they are masked by the TOP layer. I might use this idea, and supply the users with the 9 click manual method.
    – GISI
    Apr 30, 2014 at 9:38
  • There's an ArcGIS Idea for a spatial definition query that could possibly have been useful to keep most of those millions of features from drawing if it had been implemented.
    – PolyGeo
    Apr 30, 2014 at 10:07
  • PolyGeo Thank you for the idea's reference, I will vote for the idea. link
    – GISI
    May 1, 2014 at 4:09

1 Answer 1


you can use clip workspace model

In order to clip the data, you have the options to clip the features individually or set up a batch clip. However, there’s a more efficient way. With the iterator functionality available in ArcGIS 10, a simple model using the Iterate Feature Class iterator and the Clip tool can provide an efficient way to extract the subset of data. - See more at: http://blogs.esri.com/esri/supportcenter/2011/05/31/easily-clip-an-entire-workspace-for-a-specific-study-area/#sthash.aGP9LnSh.dpuf

  • Howdy, Geog. It's an idea. However I don't want to create new feature classes via geoprocessing. I need the users to point at our single point of truth (there's a lot of data in there). The visual clip to shape in the data frame properties is rather effective once it's on. I was hoping to reference it via ArcPy somehow.
    – GISI
    Apr 30, 2014 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.