I am using ArcObjects C# tool in ArcGIS that identifies map coordinates when a user clicks on a location within a map. Here's the code that I have used:

 protected override void OnMouseDown(MouseEventArgs arg)

        IMxDocument pMxDoc =(IMxDocument)ArcMap.Application.Document;
        IPoint pPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
        MessageBox.Show("Map X: " + pPoint.X + "\nMap Y: " + pPoint.Y);

My map use units of Meters so the tool displays the Meters coordinates. How can I have this tool return UTM ?

  • By UTM, do you mean MGRS or USNG or aother alphanumeric version? For instance, 11SAB23445678 or 11S 345678 4349584? – mkennedy May 3 '17 at 20:22
  • i mean WGS_1984_UTM_Zone_32N – Saif Othmani May 4 '17 at 10:10

Once you have your IPoint reference then use the Project method to project it to whatever coordinate system you like.

IGeometry.Project help from Esri

Here's a code example:

Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(t);
ISpatialReferenceFactory spatialRefFactory= obj as ISpatialReferenceFactory;
ISpatialReference spatialReference = spatialRefFactory.CreateProjectedCoordinateSystem(<ZoneNumber>);

I'm a little confused by your question since UTM is also meters, but the easiest way to change from your current coordinate system to another is to project it.

//get your desired spatial reference
ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironment() as ISpatialReferenceFactory3;
ISpatialReference spatialReference = spatialReferenceFactory.CreateSpatialReference((int)esriSRProjCSType.esriSRProjCS_WGS1984UTM_54N); 

In this case it will project to UTM 54N (1984). You can switch that out in the CreateSpatialReference parameter with any of the enumerations in:

  • esriSRProjCSType
  • esriSRProjCS2Type
  • esriSRProjCS3Type
  • esriSRProjCS4Type

There are also:

  • esriSRGeoCSType

  • esriSRGeoCS2Type

  • esriSRGeoCS3Type

if you want to go to a geographic coordinate system.

The pPoint.Project() method depends on pPoint already having a SpatialReference assigned to it. I'm not sure if the ToMapPoint() method returns a point with a SpatialReference. If pPoint doesn't have one simply assign it using the

pPoint.SpatialReference = pMxDoc.FocusMap.SpatialReference;

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.