Solved! Go to Solution.
import arcpy mxd = arcpy.mapping.MapDocument("Current") #Check for layout view if mxd.activeView == "PAGE_LAYOUT": arcpy.AddWarning( "Does not work in " + "layout view, please change to data view") sys.exit() #or whatever else: dataframe_string = mxd.activeView dataframe = arcpy.mapping.ListDataFrames(mxd, dataframe_string)[0] oldspatialref = dataframe.spatialReference spatialref = 'c:/work/arcview10/misc/WGS1984.prj' #set to wgs84 dataframe.spatialReference = spatialref #get coors of extent center in new coordinate system x = (dataframe.extent.XMin + dataframe.extent.XMax)/2 y = (dataframe.extent.YMin + dataframe.extent.YMax)/2 # set dataframe spatial ref back dataframe.spatialReference = oldspatialref #now do what you need to with the wgs84 coors
Hi Bryan,
You can try using the following GP tool which will copy the coordinates in decimal degress to your clipboard:
http://epro.maps.arcgis.com/home/item.html?id=e68ca4b6880f477ca73b3557546dc49b
import arcpy mxd = arcpy.mapping.MapDocument("Current") #Check for layout view if mxd.activeView == "PAGE_LAYOUT": arcpy.AddWarning( "Does not work in " + "layout view, please change to data view") sys.exit() #or whatever else: dataframe_string = mxd.activeView dataframe = arcpy.mapping.ListDataFrames(mxd, dataframe_string)[0] oldspatialref = dataframe.spatialReference spatialref = 'c:/work/arcview10/misc/WGS1984.prj' #set to wgs84 dataframe.spatialReference = spatialref #get coors of extent center in new coordinate system x = (dataframe.extent.XMin + dataframe.extent.XMax)/2 y = (dataframe.extent.YMin + dataframe.extent.YMax)/2 # set dataframe spatial ref back dataframe.spatialReference = oldspatialref #now do what you need to with the wgs84 coors
The tool should create the coordinates in decimal degrees. I tested against a feature class added to ArcMap (both the feature class and data frame were set to State Plane Feet). I zoomed to the extent I wanted, added a point to the lower left corner, then to the upper right (which will give me the extent). After pasting the results from the clipboard to notepad, the coordinates were in decimal degrees.
You wanted simple: This is about as simple as it gets with this kind of stuff:
Note the hard coded path to the wgs84 projection file, you will have to change that to suit your situation.
If this is not exactly what you want, hopefully it will give you some ideas and you can get your work done.
good luck,
Mike