Hello,
I am using the basic XY to line (data management) tool's syntax and am attempting to retain the input attribute fields, which is listed as a parameter of the tool, but I receive the following type error when trying to do so:
"XYToLine() takes from 0 to 9 positional arguments but 10 were given"
In the xy to line tool documentation (https://pro.arcgis.com/en/pro-app/tool-reference/data-management/xy-to-line.htm) the attribute parameter is the 10th argument (optional). Please see my syntax below for reference, w/ the attribute syntax underlined for emphasis.
arcpy.management.XYToLine("Join4_SortiesOutput", r"C:\Users\bisho\Box Sync\ALOFT\LegacyALOFT\Symbology_Layers\ALOFT_MCWL1_Data_Results.gdb\ALOFT_MCWL1_Data_Results.gdb\Results\GPD_SortieLnPro1", "FROM_X", "FROM_Y", "TO_X", "To_Y", "GEODESIC", None, "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","True")
The tool works w/o the attribute parameter included. The built in xy to line tool does not have the option to keep attributes. Any suggestions of how to get the tool working w/ this functionality?
Thanks in advance!
Penelope
Solved! Go to Solution.
What version of ArcGIS Pro do you have installed?
At version 2.6 that new parameter was added. See the toolbox history: Data Management toolbox history—ArcGIS Pro | Documentation
If you are following the 2.6 documentation, you'll see it described there. But if you do not have 2.6 installed, that is likely the cause of the error.
What version of ArcGIS Pro do you have installed?
At version 2.6 that new parameter was added. See the toolbox history: Data Management toolbox history—ArcGIS Pro | Documentation
If you are following the 2.6 documentation, you'll see it described there. But if you do not have 2.6 installed, that is likely the cause of the error.
Ah, thank you! That is the problem. I am using version 2.5.
Glad that helped. Could you mark the reply as the accepted solution to help others?
Thank you!
r"C:\Users\bisho\Box Sync\ALOFT\LegacyALOFT\Symbology_Layers\ALOFT_MCWL1_Data_Results.gdb\ALOFT_MCWL1_Data_Results.gdb\Results\GPD_SortieLnPro1"
you have a gdb within a gdb?
out_fc = r"C:\Users\bisho\BoxSync\ALOFT\LegacyALOFT\Symbology_Layers\ALOFT_MCWL1_Data_Results.gdb\ALOFT_MCWL1_Data_Results.gdb\Results\GPD_SortieLnPro1"
SR = "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"
arcpy.management.XYToLine("Join4_SortiesOutput", out_fc, "FROM_X", "FROM_Y", "TO_X", "To_Y", "GEODESIC", spatial_reference=SR, attributes="ATTRIBUTES")
Try splitting out your parameters to make it readable, at least for testing. You can use named parameters for the last two and skip any that you are using defaults for (ie, your None)