I have a CSV where each row contains 3 sets of coordinates in EPSG 32611 (UTM). I'd like to add columns that contain the coordinates in lat/long (EPSG 4326) also. So, columns H&I would be cols. B&C in lat/long; col. J&K would be cols. D&E in lat/long; and col. L&M would be F&G in lat/long:
Currently I've tried doing this by using MakeXYEventLayer for each of the three original UTM pairs (cols. B&C, D&E, F&G) and saving them into their own shapefile. I guess the next steps are to calculate geometry xy to add lat/long and then do a table join based on "PT_ID" 3x. This seems tedious and inefficient. Is there a more efficient and arc-pythonic tools I should do instead?
### STEP 2: import all points CSV generated by Matlab and cleanup
### STEP 3: make smaller, easier CSV tables for fault zone edge1 and edge2
### STEP 4: create points SHP for all points CSV
### create temp points SHP for fault zone edge1 and edge2
### STEP 5: calcualte geometry x/y in lat/long for each of 3 pairs???
### STEP 6: table join based on PT_ID, join shpOut_edge1.shp to _allCenterPoints.shp
### and then also table join, based on PT_ID, join shpOut_edge2.shp to _allCenterPoints_wEdge1.shp
import arcpy
arcpy.env.overwriteOutput = True
inputFile = r'C:\Users\X\Documents\python\Dataset_allPoints.csv'
outpath = r'C:\Users\X\Documents\python\outputs'
############################################################
### STEP 2
############################################################
import os
fileOut_allPts = outpath + '\\' + os.path.splitext(os.path.basename(inputFile))[0] + '_organized.csv'
import csv
with open(inputFile, 'r') as infile, open(fileOut_allPts, 'wb') as outfile:
columnNames = ['PT_ID', 'PT_UTMx', 'Side1_X', 'Side1_Y', 'Side2_X', 'Side2_Y']
writer = csv.DictWriter(outfile, fieldnames = columnNames)
writer.writeheader()
for row in csv.DictReader(infile):
writer.writerow(row)
del infile, outfile, columnNames, writer, row
############################################################
### STEP 3
############################################################
fileOut_edge1 = outpath + '\\' + 'temp_' + os.path.splitext(os.path.basename(inputFile))[0] + '_FaultZoneSide1.csv'
with open(inputFile, 'r') as infile, open(fileOut_edge1, 'wb') as outfile:
columnNames = ['PT_ID', 'Side1_X', 'Side1_Y']
writer = csv.DictWriter(outfile, fieldnames = columnNames, extrasaction = 'ignore')
writer.writeheader()
for row in csv.DictReader(infile):
writer.writerow(row)
del infile, outfile, columnNames, writer, row
fileOut_edge2 = outpath + '\\' + 'temp_' + os.path.splitext(os.path.basename(inputFile))[0] + '_FaultZoneSide2.csv'
with open(inputFile, 'r') as infile, open(fileOut_edge2, 'wb') as outfile:
columnNames = ['PT_ID', 'Side2_X', 'Side2_Y']
writer = csv.DictWriter(outfile, fieldnames = columnNames, extrasaction = 'ignore')
writer.writeheader()
for row in csv.DictReader(infile):
writer.writerow(row)
del infile, outfile, columnNames, writer, row
############################################################
### STEP 4
############################################################
########## Set local variables
in_Table = fileOut_allPts
inputCoordinateSystem = arcpy.SpatialReference(input_epsg)
x_coords = "PT_UTMx"
y_coords = "PT_UTMy"
z_coords = ""
out_layer = "pts_layer"
shpOut_allPts = '_allCenterPoints.shp'
# Execute MakeXYEventLayer
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_layer, inputCoordinateSystem, z_coords)
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(out_layer, outpath, shpOut_allPts)
# Clean up
del in_Table, inputCoordinateSystem, x_coords, y_coords, z_coords, out_layer
########## Set local variables
in_Table = fileOut_edge1
inputCoordinateSystem = arcpy.SpatialReference(input_epsg)
x_coords = "Side1_X"
y_coords = "Side1_Y"
z_coords = ""
out_layer = "outLayer"
shpOut_edge1 = 'temp_' + '_Edge1.shp'
# Execute MakeXYEventLayer
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_layer, inputCoordinateSystem, z_coords)
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(out_layer, outpath, shpOut_edge1)
# Clean up
del in_Table, inputCoordinateSystem, x_coords, y_coords, z_coords, out_layer
########## Set local variables
in_Table = fileOut_edge2
inputCoordinateSystem = arcpy.SpatialReference(input_epsg)
x_coords = "Side2_X"
y_coords = "Side2_Y"
z_coords = ""
out_layer = "outLayer"
shpOut_edge2 = 'temp_' + '_Edge2.shp'
# Execute MakeXYEventLayer
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_layer, inputCoordinateSystem, z_coords)
# Execute FeatureClassToFeatureClass
arcpy.FeatureClassToFeatureClass_conversion(out_layer, outpath, shpOut_edge2)
# Clean up
del in_Table, inputCoordinateSystem, x_coords, y_coords, z_coords, out_layer
############################################################
### STEP 5 calculate geometry xy lat/long for each of 3 pairs??
############################################################
# ???
############################################################
### STEP 6 multiple tabe joins???
############################################################
# multiple table joins??
Part of the table as text:
PT_ID,PT_UTMx,PT_UTMy,Side1_X,Side1_Y,Side2_X,Side2_Y
1,534738.03,3830471.97,534737.69,3830471.60,534756.47,3830491.69
2,534869.97,3830346.05,534869.63,3830345.68,534986.94,3830470.78
3,535007.99,3830214.05,535007.65,3830213.69,535071.71,3830281.79
4,535121.97,3830087.96,535121.55,3830087.69,535139.66,3830099.28
5,535206.00,3829955.98,535205.57,3829955.72,535229.06,3829970.02