Get UTM coordinates from selected map location in specific spatial reference

12-30-2019 09:12 PM
New Contributor

I'm using ArcGIS for Javascript 3.31

The users have the ability to select NAD27 or NAD83 as the projection and 16N or 17N as the zone. Then when the user clicks on the map, the application is supposed to convert the clicked point on the map to UTM coordinates in the selected projection/zone.

NAD27 16N = wkid 26716

NAD27 17N = wkid 26717

NAD83 16N = wkid 26916

NAD83 17N = wkid 26917

Code snippet looks like this:

var point = new Point(e.mapPoint.x, e.mapPoint.y, new SpatialReference({ wkid: <wkid from above>}));

var utmCoords = coordinateFormatter.toUtm(point, "north-south-indicators", true);

Anytime this runs I get the following:

Uncaught b: 

name: "coordinate-formatter: invalid-spatial-reference"

message: "wkid is not valid"

Any suggestions?

0 Kudos
1 Reply
MVP Esteemed Contributor


  The toUTM method does not allow you to specify the UTM output wkid.

Because you are providing a point that has a UTM WKID you are getting that error. The point parameter has the below note.

The location to be represented in UTM notation. The point's spatial reference should either be WGS84 or an another geographic coordinate system.

It sounds like you really want to project the mouse point to a certain UTM coordinate. For that you need to look into GeometryService Project method or the esri geometry projection class if you want to keep all the work client side.