I am receiving the following error when trying to use XY Table to Point in a Python Script:
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"C:\Users\kierc\projects\SubTelCableMap\01 Update Current Position.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">22</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>XYTableToPoint_management<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="operator token">=</SPAN>Ship_Positions_csv<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="operator token">=</SPAN>ShipLatestPosition<SPAN class="punctuation token">,</SPAN> x_field<SPAN class="operator token">=</SPAN><SPAN class="string token">"AIS.LONGITUDE"</SPAN><SPAN class="punctuation token">,</SPAN> y_field<SPAN class="operator token">=</SPAN><SPAN class="string token">"AIS.LATITUDE"</SPAN><SPAN class="punctuation token">,</SPAN> z_field<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> coordinate_system<SPAN class="operator token">=</SPAN><SPAN class="string token">"GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision"</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">3992</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> XYTableToPoint
<SPAN class="keyword token">raise</SPAN> e
File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">3989</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> XYTableToPoint
retval <SPAN class="operator token">=</SPAN> convertArcObjectToPythonObject<SPAN class="punctuation token">(</SPAN>gp<SPAN class="punctuation token">.</SPAN>XYTableToPoint_management<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">*</SPAN>gp_fixargs<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="punctuation token">,</SPAN> x_field<SPAN class="punctuation token">,</SPAN> y_field<SPAN class="punctuation token">,</SPAN> z_field<SPAN class="punctuation token">,</SPAN> coordinate_system<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">511</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN><SPAN class="keyword token">lambda</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">lambda</SPAN> <SPAN class="operator token">*</SPAN>args<SPAN class="punctuation token">:</SPAN> val<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">*</SPAN>gp_fixargs<SPAN class="punctuation token">(</SPAN>args<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcgisscripting<SPAN class="punctuation token">.</SPAN>ExecuteError<SPAN class="punctuation token">:</SPAN> Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\XYTableToPoint.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">183</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
xy_table_to_points<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> output_fc<SPAN class="punctuation token">,</SPAN> x_field<SPAN class="punctuation token">,</SPAN> y_field<SPAN class="punctuation token">,</SPAN> z_field<SPAN class="punctuation token">,</SPAN> coordinate_system<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\XYTableToPoint.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">158</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> xy_table_to_points
coord_values<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN>scur<SPAN class="punctuation token">.</SPAN>fields<SPAN class="punctuation token">.</SPAN>index<SPAN class="punctuation token">(</SPAN>val<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
ValueError<SPAN class="punctuation token">:</SPAN> tuple<SPAN class="punctuation token">.</SPAN>index<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> x <SPAN class="operator token">not</SPAN> <SPAN class="keyword token">in</SPAN> tuple
Failed to execute <SPAN class="punctuation token">(</SPAN>XYTableToPoint<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Unfortunately, I'm having trouble understanding just what this error means. This script previously ran without trouble on a previous computer. I have kept all filenames and file paths the same. Even running a normal XY Table to Point tool within ArcGIS Pro fails to complete with the following error:
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\XYTableToPoint.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">183</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
xy_table_to_points<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="punctuation token">,</SPAN> output_fc<SPAN class="punctuation token">,</SPAN> x_field<SPAN class="punctuation token">,</SPAN> y_field<SPAN class="punctuation token">,</SPAN> z_field<SPAN class="punctuation token">,</SPAN> coordinate_system<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\XYTableToPoint.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">158</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> xy_table_to_points
coord_values<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN>scur<SPAN class="punctuation token">.</SPAN>fields<SPAN class="punctuation token">.</SPAN>index<SPAN class="punctuation token">(</SPAN>val<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
ValueError<SPAN class="punctuation token">:</SPAN> tuple<SPAN class="punctuation token">.</SPAN>index<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> x <SPAN class="operator token">not</SPAN> <SPAN class="keyword token">in</SPAN> tuple
Failed to execute <SPAN class="punctuation token">(</SPAN>XYTableToPoint<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Looking for any guidance here. The code for the Python script is as follows:
<SPAN class="comment token"># -*- coding: utf-8 -*-</SPAN>
<SPAN class="string token">"""Generated by ArcGIS ModelBuilder on: 2019-12-14 00:22:34
All ModelBuilder functionality may not be exported. Edits may be required for equivalency with the original model.
"""</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token"># To allow overwriting the outputs change the overwrite option to true.</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token"># Local variables:</SPAN>
Ship_Positions_csv <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\kierc\projects\api\Ship_Positions.csv"</SPAN>
ShipLatestPosition <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\kierc\Documents\ArcGIS\Projects\SubTelCableMap\SubTelCableMap.gdb\ShipLatestPosition"</SPAN>
CurrentCableShipPositionTmp <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\kierc\Documents\ArcGIS\Projects\SubTelCableMap\SubTelCableMap.gdb\CurrentCableShipPositionTmp"</SPAN>
Updated_Target_Dataset <SPAN class="operator token">=</SPAN> CurrentCableShipPositionTmp
CurrentCableShipPosition <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\kierc\Documents\ArcGIS\Projects\SubTelCableMap\SubTelCableMap.gdb\CurrentCableShipPosition"</SPAN>
Updated_Input_With_Rows_Removed <SPAN class="operator token">=</SPAN> CurrentCableShipPosition
<SPAN class="comment token"># Process: XY Table To Point</SPAN>
tempEnvironment0 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>outputCoordinateSystem
tempEnvironment0 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>outputCoordinateSystem
arcpy<SPAN class="punctuation token">.</SPAN>XYTableToPoint_management<SPAN class="punctuation token">(</SPAN>in_table<SPAN class="operator token">=</SPAN>Ship_Positions_csv<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="operator token">=</SPAN>ShipLatestPosition<SPAN class="punctuation token">,</SPAN> x_field<SPAN class="operator token">=</SPAN><SPAN class="string token">"AIS.LONGITUDE"</SPAN><SPAN class="punctuation token">,</SPAN> y_field<SPAN class="operator token">=</SPAN><SPAN class="string token">"AIS.LATITUDE"</SPAN><SPAN class="punctuation token">,</SPAN> z_field<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> coordinate_system<SPAN class="operator token">=</SPAN><SPAN class="string token">"GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>outputCoordinateSystem <SPAN class="operator token">=</SPAN> tempEnvironment0
<SPAN class="comment token"># Process: Copy Features</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>in_features<SPAN class="operator token">=</SPAN>ShipLatestPosition<SPAN class="punctuation token">,</SPAN> out_feature_class<SPAN class="operator token">=</SPAN>CurrentCableShipPositionTmp<SPAN class="punctuation token">,</SPAN> config_keyword<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> spatial_grid_1<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> spatial_grid_2<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> spatial_grid_3<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Delete Rows</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>DeleteRows_management<SPAN class="punctuation token">(</SPAN>in_rows<SPAN class="operator token">=</SPAN>CurrentCableShipPosition<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Append</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>inputs<SPAN class="operator token">=</SPAN>r<SPAN class="string token">"C:\Users\kierc\Documents\ArcGIS\Projects\SubTelCableMap\SubTelCableMap.gdb\CurrentCableShipPositionTmp"</SPAN><SPAN class="punctuation token">,</SPAN> target<SPAN class="operator token">=</SPAN>Updated_Input_With_Rows_Removed<SPAN class="punctuation token">,</SPAN> schema_type<SPAN class="operator token">=</SPAN><SPAN class="string token">"TEST"</SPAN><SPAN class="punctuation token">,</SPAN> field_mapping<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> subtype<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> expression<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
This was originally made with Model Builder in Pro 2.4 and cleaned up/tweaked slightly by me after exporting to a editable Python file.
Edit:
For some reason, manually renaming the AIS.LATITUDE/AIS.LONGITUDE fields in my CSV file to simply LATITUDE/LONGITUDE allows the XY Table to Point tool to run successfully in ArcGIS Pro. I'm not sure why this would suddenly not work and I'd rather not having to add an additional step of renaming data fields.