1

Using following ArcPy snippet, I am able to get Extent of current map

import arcpy  
import arcpy.mapping  

## Sets the MXD file  
IMXD = arcpy.mapping.MapDocument("CURRENT")  
## Sets the Dataframe  
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]  

print DF.extent  

as:

417939.472327849 241487.977474999 477757.540444938 363798.333225001 NaN NaN NaN NaN

can you please let me know how I can grab the Envelop value from This?

3
  • 1
    it's a list of doubles! XMin = DF.extent[0], YMin = DF.extent[1] etc.. see resources.arcgis.com/en/help/main/10.2/index.html#//… which values are you really after an what format do you need them in? Commented Sep 5, 2017 at 22:16
  • @MichaelStimson I think its an Extent rather than List object that gets returned by the DataFrame's extent property.
    – PolyGeo
    Commented Sep 5, 2017 at 22:43
  • Yes @PolyGeo, there's a subtle difference. The extent property/object can be indexed like a list but also has properties (XMin, YMin etc.. as seen in your answer). I meant to say 'You can treat it like a list of doubles' though that could be dangerous - there's no guarantee in future releases indexing like a list will be accessible but the properties of an extent object are more likely to be future proof. +1 for your answer. Commented Sep 6, 2017 at 0:08

1 Answer 1

2

The DataFrame class has an extent property that returns an Extent object. That Extent object has properties like XMin, YMin, XMax and YMax that return doubles and enable you to format your envelope.

To help understand what that means try adding this at the end of your code:

print("XMin: {0}, YMin: {1}".format(DF.extent.XMin, DF.extent.YMin))
print("XMax: {0}, YMax: {1}".format(DF.extent.XMax, DF.extent.YMax))

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.