通过属性从要素转换到 3D (3D Analyst)

许可等级:BasicStandardAdvanced

摘要

使用从输入要素属性获得的高度值创建 3D 要素。

用法

语法

FeatureTo3DByAttribute_3d (in_features, out_feature_class, height_field, {to_height_field})
参数说明数据类型
in_features

用于创建 3D 要素的要素。

Feature Layer
out_feature_class

输出要素类。

Feature Class
height_field

其值被用于定义所生成的 3D 要素的高度的字段。

Field
to_height_field
(可选)

用于线的第二个可选高度字段。如果使用两个高度字段,则每条线的起点使用第一个高度,终点使用第二个高度(成坡状)。

Field

代码实例

依据属性实现要素转 3D (FeatureTo3DByAttribute) 示例 1(Python 窗口)

下面的示例演示了如何在 Python 窗口中使用此工具:

import arcpy
from arcpy import env

arcpy.CheckOutExtension('3D')
env.workspace = 'C:/data'
arcpy.FeatureTo3DByAttribute_3d('Points2D.shp', 'Points3D.shp', 'Elevation')
依据属性实现要素转 3D (FeatureTo3DByAttribute) 示例 2(独立脚本)

下面的示例演示了如何在独立 Python 脚本中使用此工具:

'''****************************************************************************
Name: FeatureTo3DByAttribute Example
Description: This script demonstrates how to use the
             FeatureTo3DByAttribute tool.
****************************************************************************'''
# Import system modules
import arcpy
import exceptions, sys, traceback
from arcpy import env

try:
    # Obtain a license for the ArcGIS 3D Analyst extension
    arcpy.CheckOutExtension('3D')
    # Set environment settings
    env.workspace = 'C:/data'
    # Set Local Variables
    InFC = 'Points_2D.shp'
    Height_Field = 'POPULATION'
    # Ensure output has unique name
    OutFC = arcpy.CreateUniqueName('Points_3D.shp')
    # Execute ConstructSightLines
    arcpy.FeatureTo3DByAttribute_3d(InFC, OutFC, Height_Field)

except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 需要 3D Analyst
ArcGIS for Desktop Standard: 需要 3D Analyst
ArcGIS for Desktop Advanced: 需要 3D Analyst
5/10/2014