Skip To Content

Terrain To Raster


Interpolates a raster from a terrain dataset.


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


TerrainToRaster_3d (in_terrain, out_raster, {data_type}, {method}, {sample_distance}, {pyramid_level_resolution}, sample_value)
ParameterExplanationData Type

The terrain dataset to process.

Terrain Layer

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

The data type of the output raster can be defined by the following keywords:

  • FLOATOutput raster will use 32-bit floating point, which supports values ranging from -3.402823466e+38 to 3.402823466e+38. This is the default.
  • INTOutput 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.

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

  • LINEARApplies 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_NEIGHBORSApplies an area based weighting scheme that uses Voronoi polygons to determine cell values.
sampling_method distance

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

  • OBSERVATIONSDefines the number of cells that divide the longest side of the output raster. This method is used by default with the value of 250.
  • CELLSIZEDefines the cell size of the output raster.

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.


The value that corresponds with the Sampling Distance for specifying the output raster's cell size.


Code sample

TerrainToRaster example 1 (Python window)

The following sample demonstrates the use of this tool in the Python window.

arcpy.env.workspace = "C:/data"
arcpy.TerrainToRaster_3d("sample.gdb/featuredataset/terrain", "terrain.tif", 
                         data_type="FLOAT", method="LINEAR", 
                         sample_distance="CELLSIZE 10", pyramid_level_resolution=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

# Set environment setting
arcpy.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)

Licensing information

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

Related topics