Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to know if it is possible to get the coordinates from a user clicked point in the current map document - arcpy.mapping.MapDocument("CURRENT")?

share|improve this question
1  
This sounds like a use case for a Python Add-in - are you using 10.1? If so, or not, can you perhaps update your tag to reflect the ArcGIS version you are using? –  PolyGeo Jan 31 '13 at 21:48
1  
Side note, I have suggested that the arcgis10 tag be a synonym of the arcgis-10.0 tag. –  blah238 Jan 31 '13 at 23:30
    
Unfortunately, I'm stuck with 10.0. I modified the title as per your suggestion. Cheers –  Brent Edwards Feb 1 '13 at 15:03

1 Answer 1

There appears to be a solution to this using a Python Add-in over at the ArcGIS Discussion Forums.

There is also a Knowledge Base Technical Article with more concise code. This also mentions that ...

"Prior to ArcGIS 10.1, Python could not be used to interact with the ArcGIS interface."

Please note that while I have just tried both I have not been able to get the button I have the code behind to activate so I cannot yet confirm that the code works. I am using ArcGIS 10.1 SP1.

My code for your reference is:

import arcpy
import pythonaddins

class ClickForXYCoordinates(object):
    """Implementation for MyPythonAddIn_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.shape = "NONE"
    def onMouseDownMap(self, x, y, button, shift):
        message = "Your mouse clicked:" + str(x) + ", " + str(y)
        pythonaddins.MessageBox(message, "My Coordinates") 
share|improve this answer
1  
This should definitely work and I have done this before at that version using Python add-ins. –  blah238 Jan 31 '13 at 23:34
    
Good find! Unfortunately, I'm stuck with ArcGIS 10.0. –  Brent Edwards Feb 1 '13 at 15:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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