Here is a quick way to switch between coordinate reference systems based on a field.
- my zone field is an integer (values are 9 or 10, indicating which NAD83 UTM Zone the point is in). Yours is text, but you can convert it to integer like below (takes zone text value, minus the last character, and converts to integer):
cur_wkid = int(wkid_shift + int(row[:-1]))
- the script relies on the wkid number being related to the zone number. In my example, I add 26900 to the zone number to get the wkid number. So, zone 9 becomes wkid = 26909 (the correct wkid for NAD83 UTM Zone 9). In your case, you need to add 31960 to the zone number. So, zone 22 becomes wkid = 31982, and zone 21 becomes wkid = 31981.
- change the values for fc, zone_field, x_field, y_field, and wkid_shift to match your data.
- you should probably make a back-up copy, just in case things go wrong.
>>> fc = 'merge' # your feature class ... fc_sr = arcpy.Describe(fc).spatialReference # get the spatial reference ... zone_field = 'UTM_Zone' # change to your zone field ... x_field = 'Easting' # change to your x field ... y_field = 'Northing' # change to your y field ... wkid_shift = 26900 # change to 31960 ... with arcpy.da.UpdateCursor(fc,['SHAPE@',zone_field,x_field,y_field],spatial_reference=fc_sr) as cursor: # loop through features ... for row in cursor: ... cur_wkid = int(wkid_shift + row) # calculate new wkid for the feature ... proj_point = row.projectAs(arcpy.SpatialReference(cur_wkid)).centroid # project a new point ... row = proj_point.X # get the x value of the new point ... row = proj_point.Y # get the y value of the new point ... cursor.updateRow(row) # write the new values to the feature