Traceback (most recent call last): File "C:\temp\GIS_projects\Sample_tripData\test.py", line 27, in <module> "TELATDD","GEODESIC","TRIPSEQNUM") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine raise e ExecuteError: ERROR 999999: Error executing function. The table was not found. [trip_lines] Failed to execute (XYToLine).
# Import system modules import arcpy print "importing modules and set environment...." from arcpy import env env.workspace = "c:/temp/gis_projects/sample_tripdata/test.gdb" fc = "trip_lines" #overwrite pre-existing files arcpy.env.overwriteOutput = True # Set local variables print "setting data input and output variables..." input_table = "C:/temp/GIS_projects/Sample_tripData/A6_TEMP_ATL_TRIP_HAULx.csv" # check to see if FC exists, if so, delete. if arcpy.Exists(fc): print "trip_lines exists..." print "deleting trip_lines..." arcpy.Delete_management(fc) print "trip_lines deleted..." out_lines = "C:/temp/GIS_projects/Sample_tripData/test.gdb/trip_lines" #XY To Line print "running XY to Line Geoprocesseing tool..." arcpy.XYToLine_management(input_table,out_lines, "TSLONGDD","TSLATDD","TELONGDD", "TELATDD","GEODESIC","TRIPSEQNUM")
Solved! Go to Solution.
Wayne,
now I need to figure out how to get it to check for null values..
# Import system modules import arcpy print "importing modules and set environment...." from arcpy import env env.workspace = "c:/temp/gis_projects/sample_tripdata/test.gdb" fc = "trip_lines" #overwrite pre-existing files arcpy.env.overwriteOutput = True # Set local variables print "setting data input and output variables..." input_table = "C:/temp/GIS_projects/Sample_tripData/A6_TEMP_ATL_TRIP_HAULx.csv" # check to see if FC exists, if so, delete. if arcpy.Exists(fc): print "trip_lines exists..." print "deleting trip_lines..." arcpy.Delete_management(fc) print "trip_lines deleted..." out_lines = "C:/temp/GIS_projects/Sample_tripData/test.gdb/trip_lines" #XY To Line print "running XY to Line Geoprocesseing tool..." arcpy.XYToLine_management(input_table,out_lines, "TSLONGDD","TSLATDD","TELONGDD", "TELATDD","GEODESIC","TRIPSEQNUM")
r'G:\PROJECTS\Cedar\GeneralScripts\PyLibrary'
out_lines = r"C:\temp\GIS_projects\Sample_tripData\test.gdb\trip_lines" or out_lines = "C:\\temp\\GIS_projects\\Sample_tripData\\test.gdb\\trip_lines"
Traceback (most recent call last): File "C:\temp\GIS_projects\Sample_tripData\test.py", line 20, in <module> arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine raise e ExecuteError: ERROR 000206: Cannot create FeatureClass tripLines Failed to execute (XYToLine).
# Import system modules import arcpy from arcpy import env print "importing modules and set environment...." #overwrite pre-existing files arcpy.env.overwriteOutput = True #set workspace env.workspace = "c:\temp\gis_projects\sample_tripdata\test.gdb" fc = "tripLines" # Set local variables print "setting data input and output variables..." input_table = r"C:\temp\GIS_projects\Sample_tripData\A6_TEMP_ATL_TRIP_HAULx.csv" #XY To Line print "running XY to Line Geoprocessing tool..." arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") # Process to delete identical line features... # Set the field upon which the identicals are found fields = "Shape;TRIPSEQNUM;Shape_Length" # Set the XY tolerance within which to identical records to be deleted xy_tol = "0.0002 Miles" # Set the Z tolerance to default z_tol = "0" print "Deleteing identical features..." # Execute Delete Identical arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol) print "Dropping leading character..." cursor = arcpy.UpdateCursor(fc) field = "TRIPSEQNUM" row = cursor.next() while row: # set value of field to only those values after the zero value location # I want to strip off the first character within the value of the field row.setValue(field, row.getValue(field)[0:]) cursor.updateRow(row) row = cursor.next() del fc, input_table, row, cursor, out_lines, input_table, field print "Processing Complete!"
>>> testPathname = "c:\temp\gis_projects\sample_tripdata\test.gdb" >>> print testPathname c: emp\gis_projects\sample_tripdata est.gdb >>>
>>> testPathname = r"c:\temp\gis_projects\sample_tripdata\test.gdb" >>> print testPathname c:\temp\gis_projects\sample_tripdata\test.gdb >>>
Traceback (most recent call last): File "C:\temp\GIS_projects\Sample_tripData\test.py", line 22, in <module> arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine raise e ExecuteError: ERROR 999999: Error executing function. The table was not found. [tripLines] Failed to execute (XYToLine).
# Import system modules import arcinfo import arcpy import sys if arcpy.CheckProduct("ArcInfo") == "Available": print "ArcInfo available, processing script..." print "importing modules and set environment...." #overwrite pre-existing files arcpy.env.overwriteOutput = True #set workspace arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb" fc = "tripLines" # Set local variables print "setting data input and output variables..." input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\A6_TEMP_ATL_TRIP_HAULx.csv" #XY To Line print "running XY to Line Geoprocessing tool..." arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") # Process to delete identical line features... # Set the field upon which the identicals are found fields = "Shape;TRIPSEQNUM;Shape_Length" # Set the XY tolerance within which to identical records to be deleted xy_tol = "0.0002 Miles" # Set the Z tolerance to default z_tol = "0" print "Deleteing identical features..." # Execute Delete Identical arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol) print "Dropping leading character..." cursor = arcpy.UpdateCursor(fc) field = "TRIPSEQNUM" row = cursor.next() while row: # set value of field to only those values after the zero value location # I want to strip off the first character within the value of the field row.setValue(field, row.getValue(field)[0:]) cursor.updateRow(row) row = cursor.next() del fc, input_table, row, cursor, out_lines, input_table, field print "Processing Complete!" else: print "ArcInfo license not available" sys.exit("ArcInfo license not available")
@Wayne, thanks.. I tried it both ways.. this time it ran through the process and executed the xytoline_management tool..
I checked the env and it was correct this time.. thanks for the heads up.. :0)
anyways, the tool ran and the csv was converted to lines.. but then it threw another error.. same as the first..
here is the error message...
Traceback (most recent call last): File "C:\temp\GIS_projects\Sample_tripData\test.py", line 22, in <module> arcpy.XYToLine_management(input_table,fc,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 2913, in XYToLine raise e ExecuteError: ERROR 999999: Error executing function. The table was not found. [tripLines] Failed to execute (XYToLine).
here is my new updated code...
# Import system modules import arcinfo import arcpy import sys if arcpy.CheckProduct("ArcInfo") == "Available": print "ArcInfo available, processing script..." print "importing modules and set environment...." #overwrite pre-existing files arcpy.env.overwriteOutput = True #set workspace arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb" fc = "tripLines" if arcpy.Exists(fc): arcpy.Delete_management(fc, "FeatureClass") featclass = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\tripLines" # Set local variables print "setting data input and output variables..." input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\A6_TEMP_ATL_TRIP_HAULx.csv" #XY To Line print "running XY to Line Geoprocessing tool..." arcpy.XYToLine_management(input_table,featclass,"TSLONGDD","TSLATDD","TELONGDD","TELATDD","GEODESIC","TRIPSEQNUM") # Process to delete identical line features... # Set the field upon which the identicals are found fields = "Shape;TRIPSEQNUM;Shape_Length" # Set the XY tolerance within which to identical records to be deleted xy_tol = "0.0002 Miles" # Set the Z tolerance to default z_tol = "0" print "Deleteing identical features..." # Execute Delete Identical arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol) print "Dropping leading character..." cursor = arcpy.UpdateCursor(fc) field = "TRIPSEQNUM" row = cursor.next() while row: # set value of field to only those values after the zero value location # I want to strip off the first character within the value of the field row.setValue(field, row.getValue(field)[0:]) cursor.updateRow(row) row = cursor.next() del fc, input_table, row, cursor, out_lines, input_table, field print "Processing Complete!" else: print "ArcInfo license not available" sys.exit("ArcInfo license not available")
I am not certain, but did notice your spatial reference parameter is not set... you should try specifying that. Sorry that's all I can think of that looks suspicious to me - oh, and I'd also avoid writing to the temp directory. The 'table not found' error can be sort of cryptic...
If you are still having difficulty, you can try attaching a portion of your csv (or all if small enough to attach here) and I'll see what I can do with it later, possibly tomorrow...
Enjoy,
Wayne
EDIT
I was curious for you to test something - see what happens if you can specify shapefile output. This may not be allowed for this tool. You can set up a different kind of test to see if you can make an event layer out of the point coordinates, then copy to a shapefile... not sure, but if you can do this to create shapefile output but not file gdb output, chances are the spatial reference is problematic. Again, just guessing without experimenting.
# Import system modules import arcinfo import arcpy import sys if arcpy.CheckProduct("ArcInfo") == "Available": print "ArcInfo available, processing script..." print "importing modules and setting environment...." #overwrite pre-existing files arcpy.env.overwriteOutput = True #delete old feature class #if arcpy.Exists("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines"): #arcpy.Delete_management ("c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines") #set workspace arcpy.env.workspace = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb" fc = "c:\\temp\\gis_projects\\sample_tripdata\\test.gdb\\haulLines" fieldName = "HaulSeqNum" # Set local variables print "gathering input table data...." input_table = "C:\\temp\\GIS_projects\\Sample_tripData\\TEST_HAUL_DATA.csv" # tool variables print "setting up variables for XY to Line management tool..." in_table = input_table out_featureclass = fc startx_field = "DLONGDD" starty_field = "DLATDD" endx_field = "RLONGDD" endy_field = "RLATDD" line_type = "GEODESIC" id_field = fieldName print "setting the spatial reference..." spatialRef = arcpy.SpatialReference("C:\\temp\\GIS_projects\\Sample_tripData\\TRIPs_GOA_STAT7.prj") #XY To Line print "running XY to Line Geoprocessing tool..." arcpy.XYToLine_management(in_table, out_featureclass, startx_field, starty_field, endx_field, endy_field,line_type,id_field,spatialRef) # Process to delete identical line features... # Set the field upon which the identicals are found fields = '"Shape;' + fieldName + ';Shape_Length"' # Set the XY tolerance within which to identical records to be deleted xy_tol = "0.0002 Miles" # Set the Z tolerance to default z_tol = "0" print "Deleteing identical features..." # Execute Delete Identical arcpy.DeleteIdentical_management(fc, fields, xy_tol, z_tol) print "Dropping leading character..." cursor = arcpy.UpdateCursor(fc) field = fieldName row = cursor.next() while row: # set value of field to only those values after the zero value location # I want to strip off the first character within the value of the field row.setValue(field, row.getValue(field)[1:]) cursor.updateRow(row) row = cursor.next() print "Processing Complete!" else: print "ArcInfo license not available" sys.exit("ArcInfo license not available")