You are here:
Extensions > Spatial Analyst > Spatial Analyst functional reference > Surface (Spatial Analyst)

# Contour

Release 9.2   Print all topics in : "Surface (Spatial Analyst)"

Creates contours or isolines from a raster surface.

Usage tips

Command line and Scripting

• Contours do not extend beyond the spatial extent of the raster, and they are not generated in areas of NoData. Therefore, adjacent contour inputs should first be edgematched into a continuous feature dataset. As an alternative to edgematching, you can merge the adjacent rasters before computing contours.

• Contours can be generated in areas of negative raster values. The contour values will be negative in such areas. Negative contour intervals are not allowed.

• Smoother but less accurate contours can be obtained by first performing a Neighborhood Focal Statistics operation with the Mean option on the input raster.

• A base contour is used, for example, when you want to create contours every 15 meters, starting at 10 meters. Here, 10 would be used for the base contour, and 15 would be the contour interval. The values to be contoured would be 10, 25, 40, 55, and so on.

• Specifying a base contour does not prevent contours from being created above or below that value.

• Map Algebra

• Contours do not extend beyond the spatial extent of the raster, and they are not generated in areas of NoData. Therefore, adjacent contour coverages should be edgematched before using the Append command to build a continuous contour coverage. As an alternative to edgematching, you can merge the adjacent rasters with Mosaic or Merge before computing contours.

• Contours can be generated in areas of negative raster values. The contour values will be negative in such areas. It is not necessary to use a negative contour interval.

• Smoother but less accurate contours can be obtained by first performing FOCALMEAN() on the input raster.

• A base contour is used, for example, when you want to create contours every 15 meters, starting at 10 meters. Here, 10 would be used for the {base}, and 15 would be the <interval>. The values to be contoured would be 10, 25, 40, 55, and so on.

• Specifying a base contour does not prevent contours from being created above or below that value.

• Learn more about how to specify the input raster dataset in the Map Algebra expression of Raster Calculator.

• ArcObjects

• Contours do not extend beyond the spatial extent of the raster, and they are not generated in areas of NoData. Therefore, adjacent contour inputs should first be edgematched into a continuous feature dataset. As an alternative to edgematching, you can merge the adjacent rasters before computing contours.

• Contours can be generated in areas of negative raster values. The contour values will be negative in such areas. Negative contour intervals are not allowed.

• Smoother but less accurate contours can be obtained by first performing a RasterNeighborhoodOp FocalStatistics operation with the Mean option on the input raster.

• A base contour is used, for example, when you want to create contours every 15 meters, starting at 10 meters. Here, 10 would be used for the [base], and 15 would be the interval. The values to be contoured would be 10, 25, 40, 55, and so on.

• Specifying a base contour does not prevent contours from being created above or below that value.

• The output from the ArcObjects method is a line feature object.

Command line syntax
An overview of the Command Line window
Contour_sa <in_raster> <out_polyline_features> <contour_interval> {base_contour} {z_factor}

 Parameter Explanation Data Type Input raster. Composite Geodataset Output contour polyline features. Feature Class Interval of contours. This can be any positive number. Double {base_contour} Base contour value. Contours are generated above and below this value as needed to cover the entire value range of the input raster. The default is zero. Double {z_factor} Number of ground x,y units in one surface z unit. The z-factor adjusts the units of measure for the z units when they are different from the x,y units of the input surface. The z-values of the input surface are multiplied by the z-factor when calculating the final output surface. If the x,y units and z units are in the same units of measure, the z-factor is 1. This is the default. If the x,y units and z units are in different units of measure, the z-factor must be set to the appropriate factor, or the results will be incorrect. For example, if your z units are feet and your x,y units are meters, you would use a z-factor of 0.3048 to convert your z units from feet to meters (1 foot = 0.3048 meter). Double
Data types for geoprocessing tool parameters

### Command line example

`Contour_sa C:/data/dem C:/data/contour.shp 10 0`

Scripting syntax
About getting started with writing geoprocessing scripts
Contour_sa (in_raster, out_polyline_features, contour_interval, base_contour, z_factor)

 Parameter Explanation Data Type in_raster (Required) Input raster. Composite Geodataset out_polyline_features (Required) Output contour polyline features. Feature Class contour_interval (Required) Interval of contours. This can be any positive number. Double base_contour (Optional) Base contour value. Contours are generated above and below this value as needed to cover the entire value range of the input raster. The default is zero. Double z_factor (Optional) Number of ground x,y units in one surface z unit. The z-factor adjusts the units of measure for the z units when they are different from the x,y units of the input surface. The z-values of the input surface are multiplied by the z-factor when calculating the final output surface. If the x,y units and z units are in the same units of measure, the z-factor is 1. This is the default. If the x,y units and z units are in different units of measure, the z-factor must be set to the appropriate factor, or the results will be incorrect. For example, if your z units are feet and your x,y units are meters, you would use a z-factor of 0.3048 to convert your z units from feet to meters (1 foot = 0.3048 meter). Double

Data types for geoprocessing tool parameters

### Script example

```# Contour_sample.py
# Description:
#   Creates contours or isolines from a raster surface.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005
# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
# Set local variables
InRaster = "C:/data/dem"
OutPolylineFeatures = "C:/data/contour.shp"
InContourInterval = "10"
InBaseContour = "0"

# Check out ArcGIS Spatial Analyst extension license
gp.CheckOutExtension("Spatial")

# Process: Contour
gp.Contour_sa(InRaster, OutPolylineFeatures, InContourInterval, InBaseContour)

except:
# If an error occurred while running a tool, then print the messages.
print gp.GetMessages()
```

Map Algebra syntax
Contour(<grid>, <INTERVAL>, <interval>, {base})

Contour(<grid>, <LIST>, <z, z, z, ..., z>)

 Parameter Explanation The raster to be contoured. Contours will be generated at regular intervals. The contour interval to be used. This can be any positive number. {base} The value from which to begin generation of contours. Contours are generated above and below this value as needed to cover the entire value range of the . The default is zero. Contours will be generated at the listed values only. The comma-delimited list of values at which to generate contours.

### Map Algebra example

```contour(elev_grd, interval, 20)
contour(elev_grd, interval, 100, 15)
contour(depth, list, -200,-50, -20, -10, 0)
contour(precipitation, list, .25, 1, 6, 12, 24, 60)```

ArcObjects syntax
ISurfaceOp::Contour (geoDataset As IGeoDataset, Interval As Double, [base As Variant]) As IGeoDataset

 Parameter Explanation geoData An input Raster, RasterDataset, RasterBand, or RasterDescriptor to be contoured. Interval The contour interval to be used. This can be any positive number. [base] The value from which to begin generation of contours. Contours are generated above and below this value as needed to cover the entire value range of the geoData. If none is specified, the contouring will begin at zero.

### ArcObjects example

```' Create the RasterSurfaceOp object
Dim pSurfaceOp As ISurfaceOp
Set pSurfaceOp = New RasterSurfaceOp

' Declare the input raster object
Dim pInputDataset As IGeoDataset

' Calls function to open a raster dataset from disk
Set pInputDataset = OpenRasterDataset("D:\SpatialData", "inputraster")

' Declare the output raster object
Dim pOutputRaster As IGeoDataset

' Calls the method
Set pOutputRaster = pSurfaceOp.Contour(pInputDataset, 50)
```

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.