Interpolate Shape (3D Analyst)

Summary

This tool interpolates z-values for a feature class based on an underlying raster, triangulated irregular network (TIN), or terrain dataset surface.

Learn more about how Interpolate Shape (3D Analyst) works

Illustration

Interpolate Shape illustration

Usage

Syntax

InterpolateShape_3d (in_surface, in_feature_class, out_feature_class, {sample_distance}, {z_factor}, {method}, {vertices_only}, {pyramid_level_resolution})
ParameterExplanationData Type
in_surface

The input raster, TIN, or terrain surface to be used as a source of z-values.

TIN Layer; Raster Layer; Terrain Layer
in_feature_class

The input 2D feature class.

Feature Layer
out_feature_class

The output feature class.

Feature Class
sample_distance
(Optional)

The spacing at which z-values will be interpolated. By default, this is a raster's cell size or a TIN's natural densification.

Double
z_factor
(Optional)

The factor by which the heights of the input surface will be multiplied to calculate new heights in the output feature class. It is used for converting z-units to match x,y units. The Z factor parameter only affects results for rasters and TINs, not terrain datasets. To apply a factor to features made from a terrain dataset use the Adjust 3D Z geoprocessing tool.

Double
method
(Optional)

Interpolation method used to define the Z values for the input features.

  • LINEAR Default interpolation method. Estimates z from the plane defined by the TIN or terrain triangle that contains the XY location of a query point.
  • NATURAL_NEIGHBORS Estimates z by applying area based weights to the TIN or terrain's natural neighbors of a query point.
  • CONFLATE_ZMIN Obtains z from one of the TIN or terrain's natural neighbors of a query point. The z of the neighbor with the minimum height is used.
  • CONFLATE_ZMAX Obtains z from one of the TIN or terrain's natural neighbors of a query point. The z of the neighbor with the maximum height is used.
  • CONFLATE_NEAREST Obtains z from one of the TIN or terrain's natural neighbors of a query point. The z of the neighbor closest in XY to the query point is used.
  • CONFLATE_CLOSEST_TO_MEAN Obtains z from one of the TIN or terrain's natural neighbors of a query point. The z of the neighbor which is closest to the average height of all the neighbors is used.
String
vertices_only
(Optional)

The sample distance will be ignored and the interpolation will use the input vertex locations only.

Boolean
pyramid_level_resolution
(Optional)

The resolution of the terrain dataset pyramid level to use for geoprocessing. The default is 0, full resolution.

Double

Code Sample

Interpolate Shape Example 1 (Python window)

The following Python Window script demonstrates how to use the Interpolate Shape function in immediate mode.

import arcpy
from arcpy import env

arcpy.CheckOutExtension("3D")
env.workspace = "C:/data"
arcpy.InterpolateShape_3d("my_tin", "roads.shp", "roads_interp.shp")
Interpolate Shape Example 2 (stand-alone script)

The following Python script demonstrates how to use the Interpolate Shape function in a stand-alone script.

'''****************************************************************************
Name: InterpolateShape Example
Description: This script demonstrates how to use the 
             InterpolateShape tool on all 2D feature classes in a target
             workspace.
****************************************************************************'''
# Import system modules
import arcpy
from arcpy import env
import exceptions, sys, traceback

try:
    # Obtain a license for the ArcGIS 3D Analyst extension
    arcpy.CheckOutExtension("3D")
    # Set environment settings
    env.workspace = "C:/data"
    # Create list of feature classes in the current workspace
    fcList = arcpy.ListFeatureClasses()
    # Determine if the list found any feature classes
    if fcList:
        # Iterate through the list
        for fc in fcList:
            desc = arcpy.Describe(fc)
            # Determine if the feature class is 2D
            if desc.hasZ is False:
               # Set Local Variables
               inSurface = "elevation_tin"
               outFC = fc[:-4] + "_3D.shp"
               method = "BILINEAR"
               # Execute InterpolateShape
               arcpy.InterpolateShape_3d(inSurface, fc, outFC, 10, 1, method, True)
            else:
               print fc + " is not a 2D feature."
            del desc, method, inSurface, outFC
    else:
        print "There are no feature classes in the " + env.workspace + " directory."

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

11/10/2011