Feature To 3D By Attribute (3D Analyst)

Summary

Creates 3D features using height values derived from the attribute of the input features.

Usage

Syntax

FeatureTo3DByAttribute_3d (in_features, out_feature_class, height_field, {to_height_field})
ParameterExplanationData Type
in_features

The features that will be used to create 3D features.

Feature Layer
out_feature_class

The output feature class.

Feature Class
height_field

The field whose values will define the height of the resulting 3D features.

Field
to_height_field
(Optional)

An optional second height field used for lines. When using two height fields, each line will start at the first height and end at the second (sloped).

Field

Code Sample

FeatureTo3DByAttribute example 1 (Python window)

The following sample demonstrates the use of this tool in the Python window:

import arcpy
from arcpy import env

arcpy.CheckOutExtension('3D')
env.workspace = 'C:/data'
arcpy.FeatureTo3DByAttribute_3d('Points2D.shp', 'Points3D.shp', 'Elevation')
FeatureTo3DByAttribute example 2 (stand-alone script)

The following sample demonstrates the use of this tool in a stand-alone Python script:

'''****************************************************************************
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)

Environments

Related Topics

Licensing Information

ArcView: Requires 3D Analyst
ArcEditor: Requires 3D Analyst
ArcInfo: Requires 3D Analyst

6/10/2013