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?
For ArcMap, arcpy.mapping.Layer has a method called GetSelectedExtent.
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):
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")