创建 XY 事件图层 (Data Management)

许可等级:BasicStandardAdvanced

摘要

根据源表中定义的 X 和 Y 坐标创建新的点要素图层。如果源表包含 Z 坐标(高程值),则可以在创建事件图层时指定该字段。由此工具创建的图层是临时图层。

了解有关将 x,y 坐标数据添加到地图的详细信息

用法

语法

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