hi MathewIt has to do with my cursor. The script was written by someone else where I am trying to add this. There is little done to capture exception and it is huge. I am not sure why my search cursor is failing here. With ok= 17 it works fine:
arcpy.CreateFeatureclass_management(scratch, outPointFileName, "POINT", "", "DISABLED", "DISABLED", srGCS83)
outPointSHP = os.path.join(scratch, outPointFileName)
# Now all we need to do is insert the point into our new shapefile.
cur = arcpy.InsertCursor(outPointSHP)
row = cur.newRow()
# It's unclear to me why *both* of these lines are needed, but it fails without the two-steps...
# What I don't fully understand is why I need "Point" and "PointGeometry"...?
point = arcpy.Point(xCoord,yCoord)
pnt = arcpy.PointGeometry(point)
#Insert the point...
row.shape = pnt
cur.insertRow(row)
del cur
##new code
try:
arcpy.AddXY_management(outPointSHP)
###New Work - Steps to know UTM zone
# Process: Add Field (7)
arcpy.AddField_management(outPointSHP, "UTM", "TEXT", "", "", "1500", "", "NULLABLE", "NON_REQUIRED", "")
# Process: Calculate UTM Zone
arcpy.CalculateUTMZone_cartography(outPointSHP, "UTM")
# Process: Add Field
arcpy.AddField_management(outPointSHP, "Lon_X", "DOUBLE", "12", "6", "", "", "NULLABLE", "NON_REQUIRED", "")
# Process: Add Field
arcpy.AddField_management(outPointSHP, "Lat_Y", "DOUBLE", "12", "6", "", "", "NULLABLE", "NON_REQUIRED", "")
# Process: Calculate Field
arcpy.CalculateField_management(outPointSHP, "Lon_X", "[POINT_X]", "VB", "")
# Process: Calculate Field
arcpy.CalculateField_management(outPointSHP, "Lat_Y", "[POINT_Y]", "VB", "")
#Get the UTM value to calculate X and Y
pointUTM= arcpy.SearchCursor(outPointSHP, "", "", "UTM;Lat_Y;Lon_X")
for row in pointUTM:
UTM_var= str(row.getValue('UTM'))[30:32]
Lat_y = row.getValue('POINT_Y')
Lon_X = row.getValue('POINT_X')
del pointUTM
###To generate fields with UTM Northing and Easting
# Process: Project
ok= '17'
out_coordinate_system = os.path.join(connectionPath+'/', r"projections/NAD1983/NAD 1983 UTM Zone %sN.prj"%ok)
arcpy.Project_management(outPointSHP, scratch+'/'+outPointPR, out_coordinate_system)