When i run this code (in arcView 10.3) in order to check the data frame extent, i received "NaN NaN" result with the exact data frame. I don't understand why python print this out? I checked in http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/dataframe-class.htm but didn't find any answer.

import arcpy

mxd = arcpy.mapping.MapDocument(r"D:\desktop\Project\project.mxd")
df = arcpy.mapping.ListDataFrames(mxd,'*')[0]
print df.name
print df.extent
del mxd

The result is:

126169.249888028 611217.599085453 149776.35592577 627939.29919552 NaN NaN NaN NaN

The reason you get the NaN-values is the following. If you look at the extent properties, described on the following page http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/extent.htm, you see the object has four more properties. These properties aren't set by default, so you'll get the NaN 'error'.

If you only want to display the XMin, YMin, XMax & YMax values you need to replace print df.extent with the following:

print str(df.extent.XMin)+ " " + str(df.extent.YMin) + " " + str(df.extent.XMax) + " " + str(df.extent.YMax)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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