My ultimate goal is to know UTM and UTM Northing and Easting. The data can be anywhere in North america. I calculated UTM using arcpy tool (arcpy.CalculateUTMZone_cartography) and I tried to truncate the value (e.g.'17N') to Project_management as part of Output coordinate string but so far no luck. Please advise.


The code is here:

arcpy.CalculateUTMZone_cartography(outPointSHP, "UTM")

pointUTM= arcpy.SearchCursor(outPointSHP)
for row in pointUTM:
    UTM_var= str(row.getValue('UTM'))[30:32]
del pointUTM

ok = UTM_var

out_coordinate_system = os.path.join(connectionPath+'/', r"projections/NAD1983/NAD 1983 UTM Zone "+ok+"N.prj")

arcpy.Project_management(outPointSHP, projPointSHP, out_coordinate_system)
  • The code works when I run in Python shell but MXD fails when I run this script in a toolbox. – Deep Aug 28 '12 at 20:25

You can make use of a trick because you're using North American zones only. Once you have the zone number, remove the 'N' and concatenate the zone number with a base value which depends on what GCS/datum you want to use.

NAD27: 267
NAD83: 269
WGS84: 326

So, NAD83 UTM zone 17N becomes 26917. The base values are the GCS well-known ID with the first digit removed. That is, geographic 2D coordinate reference system NAD83 is 4269, WGS84 is 4326, etc. This trick is not generally true--EPSG ran out of numbers, and now new objects have WKIDs assigned randomly.

There are a few exceptions, now that I double-checked:

NAD27 59N: 3370
NAD27 60N: 3371

NAD83 58N: 102213 (Esri, rather than EPSG, code)
NAD83 59N: 3372
NAD83 60N: 3373

Here's how to create a spatial reference by its WKID (factory code).

import arcpy

# Create a spatial reference object using a factory code
sr = arcpy.SpatialReference()
sr.factoryCode = 26917

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.