创建 XY 事件图层 (Data Management)
摘要
根据源表中定义的 X 和 Y 坐标创建新的点要素图层。如果源表包含 Z 坐标(高程值),则可以在创建事件图层时指定该字段。由此工具创建的图层是临时图层。
用法
- 
此工具创建的输出点要素图层是临时图层,该图层在会话结束后将不会继续存在。您可使用复制要素、要素转点或要素类至要素类工具将此事件图层导出为磁盘上的要素类。 
- 
由于事件图层不可编辑,因此无法通过编辑控件以交互方式移动输出图层中的点。除了直接移动这些点之外,还可以更改输入表中的 X 和 Y 坐标属性,然后重新创建事件图层,或将事件图层保存在磁盘上的要素类中,随后再对该要素类进行编辑。 
- 扩展名为 .csv 或 .txt 的表格文本文件的标准分隔符是逗号,扩展名为 .tab 的表格文本文件的标准分隔符是制表符。要使用具有非标准分隔符的输入表格,您必须首先使用 schema.ini 文件来指定用于表格的正确分隔符。 
- 
如果输入表中没有 ObjectID 字段,将无法进行选择或将连接添加到生成的图层。许多带分隔的文本文件或 OLE DS 连接中的表都不具有 ObjectID 字段。 
语法
MakeXYEventLayer_management (table, in_x_field, in_y_field, out_layer, {spatial_reference}, {in_z_field})
| 参数 | 说明 | 数据类型 | 
| table | 定义要创建的点要素位置的表(包含 X 和 Y 坐标)。 | Table View | 
| in_x_field | 输入表中包含 X 坐标的字段。 | Field | 
| in_y_field | 输入表中包含 Y 坐标的字段。 | Field | 
| out_layer | 输出点事件图层的名称。 | Feature Layer | 
| spatial_reference (可选) | 上文中定义的 X 和 Y 字段中坐标的空间参考。这将是输出事件图层的空间参考。 | Spatial Reference | 
| in_z_field (可选) | 输入表中包含 Z 坐标的字段。 | Field | 
代码实例
MakeXYEventLayer 示例(Python 窗口)
下面的 Python 窗口脚本演示了如何使用 MakeXYEventLayer 工具。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.MakeXYEventLayer_management("firestations.dbf", "POINT_X", "POINT_Y", "firestations_points","", "POINT_Z")
MakeXYEventLayer 示例(独立脚本)
下面的独立 Python 脚本演示了如何使用 MakeXYEventLayer 工具。
# MakeXYLayer.py
# Description: Creates an XY layer and exports it to a layer file
# import system modules 
import arcpy
from arcpy import env
# Set environment settings
env.workspace = "C:/data"
 
try:
    # 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)
 
    # Print the total rows
    print arcpy.GetCount_management(out_Layer)
 
    # Save to a layer file
    arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
 
except:
    # If an error occurred print the message to the screen
    print arcpy.GetMessages()
环境
相关主题
许可信息
ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014