Make XY Event Layer (Data Management)

Summary

Creates a 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 Export Features tool.

  • You cannot 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, and re-create the event layer, or save the event layer to a feature class on disk, and perform edits on the feature class.

  • The standard delimiter for tabular text files with a .csv or .txt extension 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 Object ID field, you cannot make selections or add joins to the resulting layer.

Parameters

LabelExplanationData Type
XY Table

The table containing the x- and y-coordinates that define the locations of the point features that will be created.

Table View
X Field

The field in the input table that contains the x-coordinates (or longitude).

Field
Y Field

The field in the input table that contains the y-coordinates (or latitude).

Field
Layer Name

The name of the output point event layer.

Feature Layer
Spatial Reference
(Optional)

The spatial reference of the coordinates specified in the X Field and Y Field parameters. This will be the output event layer's spatial reference.

Spatial Reference
Z Field
(Optional)

The field in the input table that contains the z-coordinates.

Field

arcpy.management.MakeXYEventLayer(table, in_x_field, in_y_field, out_layer, {spatial_reference}, {in_z_field})
NameExplanationData Type
table

The table containing the x- and y-coordinates that define the locations of the point features that will be created.

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

MakeXYEventLayer example (Python window)

The following Python window script demonstrates how to use the MakeXYEventLayer function.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.MakeXYEventLayer("firestations.dbf", "POINT_X", "POINT_Y", 
                                  "firestations_points", "", "POINT_Z")
MakeXYEventLayer example (stand-alone script)

The following stand-alone Python script demonstrates how to use the MakeXYEventLayer function.


# 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"NAD_1983_UTM_Zone_11N"

# Make the XY event layer...
arcpy.management.MakeXYEventLayer(in_Table, x_coords, y_coords, out_Layer, 
                                  spRef, z_coords)

# Save to a layer file
arcpy.management.SaveToLayerFile(out_Layer, saved_Layer)

Environments

Related topics