图形转要素 (转换)

摘要

根据输入图形图层的元素将图形图层转换为具有几何图形的要素图层。

使用情况

  • 一次只能将一种类型的图形元素转换为要素。

  • 文本元素将被转换为注记。 将保留元素的完整外观。

  • 此工具通常用于将图形元素的选择(子集)转换为要素

  • 如果选中转换后删除图形参数,该工具将删除图形元素并在其位置绘制新要素。 这允许一步完成转换过程。

参数

标注说明数据类型
输入图形

包含将转换为要素的源图形元素的图形图层。

Graphics Layer
图形类型

指定将转换的图形元素的类型。

  • 将转换点图形元素。
  • 折线将转换折线图形元素。
  • 将转换面图形元素。
  • 多点将转换多点图形元素。
  • 注记将转换注记和文本图形元素。
String
输出要素类

将包含转换后的图形元素的输出要素图层。

Feature Class
转换后删除图形
(可选)

指定转换后是否删除来自输入图形参数的转换图形元素。

  • 选中 - 图形元素将被删除。 这是默认设置。
  • 未选中 - 不删除图形元素,其将被保留。

Boolean
参考比例
(可选)

用于将文本元素转换为注记要素的参考比例。 当图形类型参数设置为注记时,此参数为必需项。

Double

派生输出

标注说明数据类型
更新的图层

在选中转换后删除图形参数的情况下,具有删除图形元素的更新的输入图层。

Graphics Layer

arcpy.conversion.GraphicsToFeatures(in_layer, graphics_type, out_feature_class, {delete_graphics}, {reference_scale})
名称说明数据类型
in_layer

包含将转换为要素的源图形元素的图形图层。

Graphics Layer
graphics_type

指定将转换的图形元素的类型。

  • POINT将转换点图形元素。
  • POLYLINE将转换折线图形元素。
  • POLYGON将转换面图形元素。
  • MULTIPOINT将转换多点图形元素。
  • ANNOTATION将转换注记和文本图形元素。
String
out_feature_class

将包含转换后的图形元素的输出要素图层。

Feature Class
delete_graphics
(可选)

指定转换后是否删除来自 in_layer 参数的转换图形元素。

  • DELETE_GRAPHICS转换后的图形元素将被删除。 这是默认设置。
  • KEEP_GRAPHICS不删除图形元素,其将被保留。
Boolean
reference_scale
(可选)

用于将文本元素转换为注记要素的参考比例。 当将 graphics_type 参数设置为 ANNOTATION 时,此参数为必需项。

Double

派生输出

名称说明数据类型
updated_layer

在将 delete_graphics 参数设置为 DELETE_GRAPHICS 的情况下,具有删除图形元素的更新的输入图层。

Graphics Layer

代码示例

GraphicsToFeatures 示例 1(Python 窗口)

以下 Python 代码段将包含面图形元素的图形图层从 Python 窗口转换为面要素图层。

import arcpy
arcpy.env.workspace = r"C:/data/input/myProject.aprx"
arcpy.conversion.GraphicsToFeatures("polygonGraphics", "POLYGON", 
																																				"polygonFeatures", "DELETE_GRAPHICS")
GraphicsToFeatures 示例 2(独立脚本)

以下 Python 脚本用于将点位置的图形图层添加到地图,将图形转换为要素类,计算这些点的 x,y 坐标,并将字段添加到属性表中。


# Name: GraphicsToFeatures.py
# Description: Converts a point graphics layer to a feature class and adds x,y 
# coordinate data to its attributes.
# Requirements: None

import arcpy

# Set environment
arcpy.env.workspace = r"C:\Data"

# Set local variables
in_layer = "graphics_coord.lyrx"
out_path = "Default.gdb"
geometry_type = "POINT"
result = arcpy.management.CreateFeatureclass(out_path, "out_fc", geometry_type)

# Execute the conversion
arcpy.conversion.GraphicsToFeatures(in_layer, 'POINT', result, 'DELETE_GRAPHICS')

# Add x,y coordinates to the new feature class
arcpy.management.AddXY("out_fc")

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题