How to find the extent of layer that was created with MakeFeatureLayer

04-28-2021 10:05 PM
Occasional Contributor III

I work in arcpy for ArcMap and do MakeFeatureLayer with some expression.

Then I need to find the extent of this layer.

Describe on the layer name gives the original extent (without  the query)

I know I can do a search cursor and union the extent of all features but I would like to avoid it.

I can also do a CopyFeatures but this will create extra layer.

Any other ideas?


0 Kudos
2 Replies
Occasional Contributor III

For ArcMap, arcpy.mapping.Layer has a method called GetSelectedExtent.

ArcPy - Mapping module - Classes - Layer 


For Pro users, unfortunately it does not have this method, but there is a solution here (yes, uses search cursor but does not union so should be fairly quick): Get Selected Features Extent 

Occasional Contributor III

The problem is to get the Layer.

After more testing, this looks like it works

arcpy.MakeFeatureLayer_management(r"C:\temp\data.gdb\City","bb","objectid < 10")
lyr = arcpy.mapping.Layer("bb")


0 Kudos