ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Terrain To Raster

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Interpolates a raster using z-values from a terrain dataset.

Usage

  • The resolution parameter indicates which pyramid level of the terrain to use for conversion. Pyramid levels are defined using the z-tolerance or window-size pyramid types. For more information on terrain pyramids, see Terrain Pyramids.

  • To extract a subset of the terrain, define the extent using the geoprocessing environment settings.

  • The Linear and Natural neighbor interpolation options are applied through the triangulated terrain surface. The linear option finds the triangle encompassing each cell center and applies a weighted average of the triangle's nodes to interpolate a value. The natural neighbors option uses area-based weights on Voronoi neighbors.

Syntax

arcpy.ddd.TerrainToRaster(in_terrain, out_raster, {data_type}, {method}, {sample_distance}, {pyramid_level_resolution})
ParameterExplanationData Type
in_terrain

The terrain dataset to process.

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, such as .tif to generate a GeoTIFF or .img to generate an ERDAS IMAGINE format file.

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
(Optional)

Specifies the type of numeric values stored in the output raster.

  • FLOAT —Output raster will use 32-bit floating point, which supports values ranging from -3.402823466e+38 to 3.402823466e+38. This is the default.
  • INT —Output raster will use an appropriate integer bit depth. This option will round z-values to the nearest whole number and write an integer to each raster cell value.
String
method
(Optional)

The interpolation method that will be used to calculate cell values.

  • LINEAR —Applies a distance based weight to the Z of each node in the triangle encompassing the center of a given cell, then sums the weighted values to assign the cell value. This is the default.
  • NATURAL_NEIGHBORS —Applies an area based weighting scheme that uses Voronoi polygons to determine cell values.
String
sample_distance
sampling_method distance
(Optional)

The sampling method and distance used to define the cell size of the output raster.

String
pyramid_level_resolution
(Optional)

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

Code sample

TerrainToRaster 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.TerrainToRaster_3d("sample.gdb/featuredataset/terrain", "terrain.img", "INT", "LINEAR", "CELLSIZE 10", 2.5)
TerrainToRaster example 2 (stand-alone script)

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)

Environments

  • Current Workspace
  • Output Coordinate System
  • Extent
  • Snap Raster
  • Pyramid
  • Compression
  • Output CONFIG Keyword
  • Auto Commit
  • Raster Statistics
  • Terrain Memory Usage

Licensing information

  • Basic: Requires 3D Analyst
  • Standard: Requires 3D Analyst
  • Advanced: Requires 3D Analyst

Related topics

  • An overview of the Conversion toolset
  • Fundamentals of geoprocessing with the ArcGIS 3D Analyst extension
  • Surface formats

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal