1

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.

Thanks

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 arcpy.AddMessage(ok) 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) 
1
  • The code works when I run in Python shell but MXD fails when I run this script in a toolbox. Commented Aug 28, 2012 at 20:25

1 Answer 1

2

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 sr.create() 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.