Summary
Creates a new point feature layer based on x- and y-coordinates defined in a table. If the source table contains z-coordinates (elevation values), that field can also be specified in the creation of the event layer. The layer created by this tool is temporary.
Usage
The output point feature layer created by this tool is temporary and will not persist after the session ends. You can export this event layer to a feature class on disk using the Copy Features, Feature to Point, or Feature Class to Feature Class tool.
It is not possible to interactively move the output layer's points through editing controls, since event layers are not editable. Alternatives to directly moving these points are to change the x- and y-coordinate attributes in the input table, then re-create the event layer, or save the event layer to a feature class on disk, then perform edits on the feature class.
The standard delimiter for tabular text files with extensions .csv or .txt is a comma, and for files with a .tab extension, a tab. To use an input table with a nonstandard delimiter, you must first specify the correct delimiter used in the table using a schema.ini file.
If the input table does not have an ObjectID field, you will not be able to make selections or add joins to the resulting layer.
Syntax
arcpy.management.MakeXYEventLayer(table, in_x_field, in_y_field, out_layer, {spatial_reference}, {in_z_field})
Parameter | Explanation | Data Type |
table | The table containing the x- and y-coordinates that define the locations of the point features to create. | Table View |
in_x_field | The field in the input table that contains the x-coordinates (or longitude). | Field |
in_y_field | The field in the input table that contains the y-coordinates (or latitude). | Field |
out_layer | The name of the output point event layer. | Feature Layer |
spatial_reference (Optional) | The spatial reference of the coordinates specified in the in_x_field and in_y_field parameters. This will be the output event layer's spatial reference. | Spatial Reference |
in_z_field (Optional) | The field in the input table that contains the z-coordinates. | Field |
Code sample
The following Python window script demonstrates how to use the MakeXYEventLayer tool.
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.MakeXYEventLayer_management("firestations.dbf", "POINT_X", "POINT_Y",
"firestations_points", "", "POINT_Z")
The following stand-alone Python script demonstrates how to use the MakeXYEventLayer tool.
# Description: Creates an XY layer and exports it to a layer file
# import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = "C:/data"
# Set the local variables
in_Table = "firestations.dbf"
x_coords = "POINT_X"
y_coords = "POINT_Y"
z_coords = "POINT_Z"
out_Layer = "firestations_layer"
saved_Layer = r"c:\output\firestations.lyr"
# Set the spatial reference
spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj"
# Make the XY event layer...
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer,
spRef, z_coords)
# Save to a layer file
arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes