插值 Shape (3D Analyst)

许可等级:BasicStandardAdvanced

摘要

根据从栅格、不规则三角网 (TIN)、或 terrain 数据集获取的高程值为要素类插入 z 值。

了解有关“插值 Shape”工作原理的详细信息

插图

Interpolate Shape illustration

用法

语法

InterpolateShape_3d (in_surface, in_feature_class, out_feature_class, {sample_distance}, {z_factor}, {method}, {vertices_only}, {pyramid_level_resolution})
参数说明数据类型
in_surface

用于内插 z 值的 LAS 数据集、栅格、TIN 或 terrain 表面。

LAS Dataset Layer, Raster Layer; Terrain Layer; TIN Layer
in_feature_class

输入的要素类。

Feature Layer
out_feature_class

输出要素类。

Feature Class
sample_distance
(可选)

用于内插 z 值的间距。默认情况下,该参数是栅格的像元大小或 TIN 的自然增密。

Double
z_factor
(可选)

Z 值将乘上的系数。此值通常用于转换 Z 线性单位来匹配 XY 线性单位。默认值为 1,此时高程值保持不变。

Double
method
(可选)

用于确定输出要素的高程值的插值方法。可用选项取决于正在使用的表面类型。BILINEAR 插值可用于栅格表面,查询点根据四个最邻近的像元中找到的值获取其高程。Terrain 和 TIN 数据集提供了以下选项:

  • LINEAR 默认插值方法。根据由三角形(包含查询点 XY 位置)定义的平面获取高程。
  • NATURAL_NEIGHBORS 通过将基于区域的权重应用于查询点的自然邻域获取高程。
  • CONFLATE_ZMIN 根据在查询点自然邻域中找到的最小 Z 值获取高程。
  • CONFLATE_ZMAX 根据在查询点自然邻域中找到的最大 Z 值获取高程。
  • CONFLATE_NEAREST 根据查询点自然邻域中的最近值获取高程。
  • CONFLATE_CLOSEST_TO_MEAN 根据距查询点所有自然邻域的平均值最近的 Z 值获取高程。
String
vertices_only
(可选)

指定是否仅沿输入要素的折点进行插值,从而忽略采样距离选项。

  • DENSIFY使用采样距离插值。这是默认设置。
  • VERTICES_ONLY沿折点插值。
Boolean
pyramid_level_resolution
(可选)

此工具将使用 terrain 金字塔等级的 z 容差或窗口大小分辨率。默认值为 0(z 容差),或全分辨率(窗口大小)。

Double

代码实例

插值 Shape (InterpolateShape) 示例 1(Python 窗口)

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

import arcpy
from arcpy import env

arcpy.CheckOutExtension("3D")
env.workspace = "C:/data"
arcpy.InterpolateShape_3d("my_tin", "roads.shp", "roads_interp.shp")
插值 Shape (InterpolateShape) 示例 2(独立脚本)

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

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

# Set local variables
inWorkspace = arcpy.GetParameterAsText(0)
surface = arcpy.GetParameterAsText(1)

try:
    arcpy.CheckOutExtension("3D")
    # Set default workspace
    env.workspace = inWorkspace
    # Create list of feature classes in target workspace
    fcList = arcpy.ListFeatureClasses()
    if fcList:
        for fc in fcList:
            desc = arcpy.Describe(fc)
            # Find 2D features
            if not desc.hasZ:
                # Set Local Variables
                outFC = "{0}_3D.shp".format(desc.basename)
                method = "BILINEAR"
                # Execute InterpolateShape
                arcpy.ddd.InterpolateShape(surface, fc, outFC, 
                                           10, 1, method, True)
            else:
                print "{0} is not a 2D feature.".format(fc)
    else:
        print "No feature classes were found in {0}.".format(env.workspace)
    arcpy.CheckInExtension('3D')
    
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