how to get center coordinates from map viewer?

1618
3
Jump to solution
11-10-2016 09:41 AM
EricEagle
Occasional Contributor III

I figured that this one would be pretty easy, but I'm having trouble finding it via google.

How do I (with arcpy/python) get current map viewer center coordinates or corner coordinates?

I'm constructing geospatial URL queries, and I want the tool to automatically send the viewer center point, or the 4 corner coordinates, as part of the URL payload.

0 Kudos
1 Solution

Accepted Solutions
LukeWebb
Occasional Contributor III
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]   #the 1st data frame
print df.extent
print df.extent.XMin
print df.extent.XMax

print df.extent.YMin
print df.extent.YMax

View solution in original post

3 Replies
LukeWebb
Occasional Contributor III
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]   #the 1st data frame
print df.extent
print df.extent.XMin
print df.extent.XMax

print df.extent.YMin
print df.extent.YMax
EricEagle
Occasional Contributor III

Great! Thanks Luke!

0 Kudos
ClintonDow1
Occasional Contributor II

Hello Eric,

If I understand you correctly you'll want to look at DataFrame Objects and its extent property (in 10.x) or Camera Objects (in Pro) which uses the getExtent() - Both of these should return an Extent Object from which you can get the XMin, Ymin, Xmax & Ymax properties from to figure out the center point.