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.
Illustration
![]() |
Usage
-
When using the natural neighbors interpolation option, make sure to specify a reasonable sample distance. This usually falls between 0.5 and 1.0 times the average point spacing of the data used to build the TIN or terrain dataset.
-
When using the Interpolate Vertices Only option, input features with vertices that fall outside the data area of the surface will be ignored and not output. Clip features prior to running Interpolate Shape to ensure the features are completely on the surface.
The Z factor parameter only affects results for rasters and TINs, not terrain datasets. To apply a z factor to features made from a terrain dataset use the Adjust 3D Z geoprocessing tool.
Syntax
| Parameter | Explanation | Data 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.
| 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
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")
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)
