1

Is there a way to select grouped layers within a specific extent with ArcGIS 10.5?

For example I have a constraint mapping, with various thematic layers grouped by interest. I would like to know which one are applicable in my project area, without having to select and clip each layer individually (too many of them). Ideally a tool that would let me grab the group of layer and create a shp or layer of features present within my work area would be great.

1
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Please check out our short tour to learn about our focussed Q&A format. For anything like this I would use ArcPy. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely.
    – PolyGeo
    Commented Oct 5, 2018 at 1:39

1 Answer 1

2

Assuming the layers are all in the current MXD, you could try something like this using Python and arcpy:

extentOfInterest = arcpy.Extent(xmin, ymin, xmax, ymax)
mxd = arcpy.mapping.MapDocument("CURRENT")

for layer in arcpy.mapping.ListLayers(mxd):
    if extentOfInterest.overlaps(layer.getExtent()):
        print "Layer overlaps and will be processed:  " + layer.longName
        #  Clip, etc here

Replacing xmin, ymin, xmax and ymax with the minimum and maximum values for your extent of interest. You could even turn it into a script tool, and pass these values in as parameters.

Alternatively, you could create the extentOfInterest as the envelope of a polygon feature.

Optionally, you can filter the layers by the layers' names (as a wildcard string in the ListLayers()), or by which group they are in (using the layer.longName, which includes group hierarchy), to process only the layers that you're interested in.

UPDATE: As suggested in comments below, you may also want to filter the layers based on layer.isFeatureLayer and/or layer.isGroupLayer. It depends on what your needs actually are.

3
  • 1
    From the sound of the question you might need a nested for layer loop, if layer.isGroupLayer: for gLayer in arcpy.mapping.ListLayers(layer): as the OP is looking at group layers that intersect, presumably at least one layer. You should also test if gLayer.isFeatureLayer before using overlap.. but just because a layers' extent overlaps doesn't mean there's features in the area of interest, at some point you'd need to do a select layer by location and return a selection count. Commented Oct 5, 2018 at 2:14
  • 1
    Good points. I think I might leave it simple for now though, as the question is a little vague. Commented Oct 5, 2018 at 2:16
  • Thanks for your help. I was hoping for a way to proceed without a python script as my scripting knowledge is fairly basic but will give it a go.
    – Anna
    Commented Oct 9, 2018 at 0:58

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