Summary
Creates a new feature class containing geodetic line features constructed based on the values in a start x-coordinate field, start y-coordinate field, end x-coordinate field, and end y-coordinate field of a table.
Usage
If you use text files and .csv (comma-separated value) files as input, make sure that they follow the file structure specified in About tabular data sources.
Each geodetic line is constructed using a particular set of field values representing the x and y coordinates of a starting point and the x and y coordinates of an ending point. These fields and values will be included in the output.
A geodetic line is a curve on the surface of the earth. However, a geodetic line feature is not stored as a parametric (true) curve in the output, but as a densified polyline representing the path of the geodetic line. If the length of a geodetic line is relatively short, it may be represented by a straight line in the output. As the length of the line increases, more vertices are used to represent the path.
When the output is a feature class in a file geodatabase or a personal geodatabase, the values in the Shape_Length field are always in the units of the output coordinate system specified by the Spatial Reference parameter; and they are the planar lengths of the polylines. To measure a geodesic length or distance, use the ArcMap Measure tool; make sure to choose the Geodesic, Loxodrome, or Great Elliptic option accordingly before taking a measurement.
Syntax
XYToLine(in_table, out_featureclass, startx_field, starty_field, endx_field, endy_field, {line_type}, {id_field}, {spatial_reference})
Parameter | Explanation | Data Type |
in_table | The input table that can be a text file, CSV file, Excel file, dBASE table, or geodatabase table. | Table View |
out_featureclass | The output feature class containing densified geodetic lines. | Feature Class |
startx_field | A numerical field in the input table containing the x coordinates (or longitudes) of the starting points of lines to be positioned in the output coordinate system specified by the spatial_reference parameter. | Field |
starty_field | A numerical field in the input table containing the y coordinates (or latitudes) of the starting points of lines to be positioned in the output coordinate system specified by the spatial_reference parameter. | Field |
endx_field | A numerical field in the input table containing the x coordinates (or longitudes) of the ending points of lines to be positioned in the output coordinate system specified by the spatial_reference parameter. | Field |
endy_field | A numerical field in the input table containing the y coordinates (or latitudes) of the ending points of lines to be positioned in the output coordinate system specified by the spatial_reference parameter. | Field |
line_type (Optional) | The type of geodetic line to construct.
| String |
id_field (Optional) | A field in the input table; this field and the values are included in the output and can be used to join the output features with the records in the input table. | Field |
spatial_reference (Optional) | The spatial reference of the output feature class. You can specify the spatial reference in several ways:
| Spatial Reference |
Code sample
XYToLine example (stand-alone script)
This sample converts a DBF table to two-point Geodesic lines.
# Import system modules
import arcpy
from arcpy import env
# Set local variables
input_table = r"c:\workspace\city2city.dbf"
out_lines = r"c:\workspace\flt4421.gdb\routing001"
#XY To Line
arcpy.XYToLine_management(input_table,out_lines,
"LOND1","LATD1","LOND2",
"LATD2","GEODESIC","idnum")
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes