# How do I get the coordinates of my data frame always in long/lat?

I want to determine the coordinates of my current data frame. To do so I wrote this script:

``````def DataFrame ():

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
return mxd,df

def Center (df):

extent = df.extent
xmin = extent.XMin
xmax = extent.XMax
ymin = extent.YMin
ymax = extent.YMax

x = xmax - ((xmax - xmin)/2)
y = ymax - ((ymax - ymin)/2)
return x,y
``````

As long as I am working with a geographic coordinate system, the results will be exactly the longitude and latitude. But as soon as I have a projected coordinate system it will return map units (i.e. meters). How can I avoid that problem? I always need to get lon/lat independend on the maps projection.

• Have you looked at the Convert Coordinate Notation tool?
– PolyGeo
Aug 9, 2013 at 9:56
• Hmm, as far as I understand it right, this would mean that I have to create tables for the values that can then be converted. I was hoping that there is a much easier way like just using "arcpy.convertCoordinates" or something. Aug 9, 2013 at 10:07

Try using the `projectAs` function available on your `Extent` object:
``````extent_geographic = df.extent.projectAs(arcpy.SpatialReference(4326)) # GCS_WGS_1984