XY To Line (Data Management)

License Level:BasicStandardAdvanced

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

Syntax

XYToLine_management (in_table, out_featureclass, startx_field, starty_field, endx_field, endy_field, {line_type}, {id_field}, {spatial_reference})
ParameterExplanationData 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.

  • GEODESIC A type of geodetic line which most accurately represents the shortest distance between any two points on the surface of the earth. The mathematical definition of the geodesic line is quite lengthy and complex and therefore omitted here. This line type is the default.
  • GREAT_CIRCLEA type of geodetic line which represents the path between any two points along the intersection of the surface of the earth and a plane that passes through the center of the earth. Depending on the output coordinate system specified by the Spatial Reference parameter, in a spheroid-based coordinate system, the line is a great elliptic; in a sphere-based coordinate system, the line is uniquely called a great circle—a circle of the largest radius on the spherical surface.
  • RHUMB_LINEA type of geodetic line, also known as a loxodrome line, which represents a path between any two points on the surface of a spheroid defined by a constant azimuth from a pole. A rhumb line is shown as a straight line in the Mercator projection.
  • NORMAL_SECTIONA type of geodetic line which represents a path between any two points on the surface of a spheroid defined by the intersection of the spheroid surface and a plane that passes through the two points and is normal (perpendicular) to the spheroid surface at the starting point of the two points. Therefore, the normal section line from point A to point B is different from the one from point B to point A.
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:

  • By entering the path to a .prj file, such as C:/workspace/watershed.prj.
  • By referencing a feature class or feature dataset whose spatial reference you want to apply, such as C:/workspace/myproject.gdb/landuse/grassland.
  • By defining a spatial reference object prior to using this tool, such as sr = arcpy.SpatialReference("C:/data/Africa/Carthage.prj"), which you then use as the spatial reference parameter.

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

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015