Terrain 转栅格 (3D Analyst)
摘要
将 terrain 数据集转换为栅格。
用法
-
分辨率参数表示用于转换的 terrain 的金字塔等级。金字塔等级是通过使用 z 容差或窗口大小的金字塔类型定义的。有关 terrain 金字塔的详细信息,请参阅 terrain 金字塔。
-
要提取 terrain 子集,请使用地理处理环境设置定义范围。
-
可用的插值法选项是 LINEAR 和 NATURAL_NEIGHBORS。这些方法是在三角化 terrain 表面上应用的基于 TIN 的方法。线性选项可找到包围每个像元中心的三角形,并会应用三角形的结点的加权平均值来执行插值计算。自然邻域法选项使用 Voronoi 邻域的基于区域的权重。
-
输出栅格可能是基于文件的,也可能作为地理数据库中的栅格数据集创建。基于文件的栅格格式由给栅格指定的扩展名决定。例如,使用扩展名“.img”和“.tif”将生成 IMAGINE 或 TIFF 文件。如果栅格不包含文件扩展名,则将生成 Esri GRID。
语法
参数 | 说明 | 数据类型 |
in_terrain |
The input terrain dataset. | Terrain Layer |
out_raster |
The location and name of the output raster. When storing a raster dataset in a geodatabase or in a folder such as an Esri Grid, no file extension should be added to the name of the raster dataset. A file extension can be provided to define the raster's format when storing it in a folder:
If the raster is stored as a TIFF file or in a geodatabase, its raster compression type and quality can be specified using geoprocessing environment settings. | Raster Dataset |
data_type (可选) |
The data type of the output raster can be defined by the following keywords:
| String |
method (可选) |
选择插值法。默认情况下,使用 LINEAR 方法计算像元值。
| String |
sample_distance sampling_method distance (可选) |
The sampling method and distance used to define the cell size of the output raster.
| String |
pyramid_level_resolution (可选) |
The z-tolerance or window size resolution of the terrain pyramid level that will be used by this tool. The default is 0, or full resolution. | Double |
代码示例
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.TerrainToRaster_3d("sample.gdb/featuredataset/terrain", "terrain.img", "INT", "LINEAR", "CELLSIZE 10", 2.5)
The following sample demonstrates the use of this tool in a stand-alone Python script:
'''********************************************************************* Name: TerrainToRaster Example Description: This script demonstrates how to use the TerrainToRaster tool. **********************************************************************''' # Import system modules import arcpy from arcpy import env import exceptions, sys, traceback try: arcpy.CheckOutExtension("3D") # Set environment setting env.workspace = "C:/data" # Set Local Variables terrain = "sample.gdb/featuredataset/terrain" bitType = "INT" method = "LINEAR" sampling = "CELLSIZE 10" pyrLvl = 2.5 outRas = arcpy.CreateUniqueName("terrain_level.img") #Execute TerrainToRaster arcpy.ddd.TerrainToRaster(terrain, outRas, bitType, method, sampling, pyrLvl) 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)