Skip To Content

Generate Topographic Contours

Summary

Creates and smooths contours from an input raster.

Usage

  • This tool supports local raster files only.

  • If more than one input raster is used, all input rasters must have the same cell size, band count, and pixel type. All input rasters should also use the same elevation units (meters or feet).

  • The area of interest (AOI) is used to limit the extent over which the contours will be created. Typically, the AOI will be a polygon feature that represents the extent of a map sheet at the specified scale. The AOI will be buffered to ensure that contours extend to the full edge of the sheet and to reduce edge matching issues between sheets. Contours will only be created over the portions of the rasters that overlap the buffer AOI.

  • The scale is used to refine the appearance of the contours to be optimized for print and display at that scale. The scale determines the default values for the Contour and Contour Index Interval values, as well as for the minimum length of the contours and the smoothing tolerance that will be used to refine the appearance of the contours. When the scale and any of the parameters that get a default value from it are left blank, the tool will get default values from the 1:50,000 scale.

  • This tool optionally supports smoothing of the input rasters before creating the contour lines. When a Raster Smooth Tolerance value is set, the tool uses Adaptive Smoothing from the Contour raster function to prepare the raster before generating contour lines. Depending on the tolerance used, the result may be contour lines that are smoother and more cartographically pleasing but less accurate.

  • This tool does not create a new output feature class but adds the contours to an existing feature class. Most topographic agencies have defined the feature class, subtypes, and attributes appropriate for describing their elevation features in their existing data schema. Rather than creating a new output that must be mapped into that schema as a postprocess, this tool will add the results directly into the chosen feature class.

  • 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.

  • In addition to the contour elevation, this tool can be used to populate the Contour Code Field with information about the type of contour. When a Contour Code Field is chosen, the following parameters should also be set to ensure the values in the field are correctly populated.

    • The Contour Index Interval will be used to distinguish index contours from intermediate contours.
    • The Index Code is the value that will be populated in the Contour Code Field when the elevation of the contour is evenly divisible by the index interval and the contours are increasing in elevation.
    • The Intermediate Code is the value that will be populated in the Contour Code Field when the elevation of the contour is not evenly divisible by the index interval and the contours are increasing in elevation.
    • The Depression Code is the value that will be populated in the Contour Code Field when the elevation of the contour is evenly divisible by the index interval and the contours are decreasing in elevation.
    • The Depression Intermediate Code is the value that will be populated in the Contour Code Field when the elevation of the contour is not evenly divisible by the index interval and the contours are decreasing in elevation.

  • The tool is optimized to support various Defense Mapping data model schemas. If the feature class chosen as the Out Contour Features matches one of these schemas, the values for the Contour Height Field, Contour Subtype, Contour Code Field, Index Code, Intermediate Code, Depression Code, and Depression Intermediate Code parameters will automatically be set to the values appropriate for that schema.

  • The geometry of the contours can be further refined after they are created. Specifying a Contour Minimum Length will remove any isolated contours smaller than the specified length. For example, a contour line that encloses a peak but is only 10 meters long may be too short to be clearly visualized on a 1:100,000 scale map. Depending on the cell size of the input raster, the contour lines could have a coarse, blocky appearance. The Contour Smooth Tolerance will apply a line smoothing algorithm to the contour lines to help refine sharp angles and create smoother contours.

Syntax

GenerateTopographicContours_topographic (in_rasters, area_of_interest, contour_features, elevation_field, {contour_subtype}, {scale}, {resample_raster}, {contour_interval}, {base_contour}, {z_factor}, {zero_contour}, {code_field}, {index_interval}, {index_code}, {intermediate_code}, {depression_code}, {depression_intermediate_code}, {raster_smooth_tolerance}, {minimum_length}, {contour_smooth_tolerance})
ParameterExplanationData Type
in_rasters
[in_rasters,...]

The input raster layers used to derive the contour lines.

Raster Layer; Mosaic Layer
area_of_interest

A feature layer that is used to clip the input raster before processing. A buffer is created before clipping the raster and results in larger output contours that extend beyond the selected AOI. The feature layer must have only one selected feature.

Feature Layer
contour_features

An existing line feature class or feature layer. Contours will be appended to this feature class.

Feature Layer
elevation_field

The field from the input contours that will store the contour elevation value. This field defaults to ZV2 or ZVH if a field with either of those names exists in the contour feature class.

Field
contour_subtype
(Optional)

If the input contours have subtypes, the subtype to which contours will be written.

String
scale
(Optional)

The scale that the contours will be optimized for (in other words, the scale of the cartographic product will be printed). Choosing the scale will set the defaults of the following parameters to values that are appropriate for the output scale. The default value is 1:50,000 cartographic product scale.

  • 1:5,0001:5,000 cartographic product scale
  • 1:10,0001:10,000 cartographic product scale
  • 1:12,5001:12,500 cartographic product scale
  • 1:25,0001:25,000 cartographic product scale
  • 1:50,0001:50,000 cartographic product scale. This is the default value.
  • 1:100,0001:100,000 cartographic product scale
  • 1:250,0001:250,000 cartographic product scale
  • 1:500,0001:500,000 cartographic product scale
  • 1:1,000,0001:1,000,000 cartographic product scale
String
resample_raster
(Optional)

Specifies if the input raster will be resampled before creating contours.

  • RESAMPLE_RASTERThe input raster will be resampled before creating contours. This is the default.
  • NO_RESAMPLE_RASTERThe input raster will not be resampled when creating contours.
Boolean
contour_interval
(Optional)

The interval, or distance, between contour lines. This can be any positive number. The default is set by the chosen scale. If the value is left blank, the default value for the chosen scale will be used during processing.

Double
base_contour
(Optional)

Contours are generated above and below this value to cover the entire value range of the input raster. The default is 0.

Double
z_factor
(Optional)

The unit conversion factor used when generating contours. The default value is 1.

The contour lines are generated based on the z-values in the input raster, which are often measured in units of meters or feet. With the default value of 1, the contours will be in the same units as the z-values of the input raster. To create contours in a different unit than that of the z-values, set an appropriate value for the z-factor. Note that it is not necessary to have the ground x,y and surface z-units be consistent for this tool.

For example, if the elevation values in your input raster are in feet, but you want the contours to be generated based on units of meters, set the z-factor to 0.3048 (since 1 foot = 0.3048 meters).

Double
zero_contour
(Optional)

Specifies if the tool will create a zero contour. A zero contour represents sea level. Zero contours, when generated along a coastline, may be created inside a water body. Specify ZERO_CONTOUR if you will generate contours on land areas that are at or below sea level.

  • ZERO_CONTOURCreate a zero contour.
  • NO_ZERO_CONTOURDo not create a zero contour. This is the default.
Boolean
code_field
(Optional)

A field from the input contour feature class where the appropriate code will be stored. The field defaults to the HQC field if it exists in the input contour feature class.

Field
index_interval
(Optional)

The interval, or distance, between index contour lines. For example, if the contour interval is 20 meters and you wanted index contours every 100 meters, specify 100. The default is set by the chosen scale.

Long
index_code
(Optional)

The code value to be stored in the Contour Code Field (code_field in Python) when an index contour is identified. The default code will be 1 if the HQC field exists in the input contour feature class.

String
intermediate_code
(Optional)

The code value to be stored in the Contour Code Field (code_field in Python) when an intermediate contour is identified. The default code will be 2 if the HQC field exists in the input contour feature class.

String
depression_code
(Optional)

The code value to be stored in the Contour Code Field (code_field in Python) when a depression contour is identified. The default code will be 5 if the HQC field exists in the input contour feature class.

String
depression_intermediate_code
(Optional)

The code value to be stored in the Contour Code Field (code_field in Python) when a depression intermediate contour is identified. The default code will be 61 if the HQC field exists in the input contour feature class.

String
raster_smooth_tolerance
(Optional)

The amount of smoothing applied to the input raster before creating the contour lines.

Double
minimum_length
(Optional)

The minimum length for an individual contour line. The default value is set by the chosen scale. If the value is set to 0 or left blank, no contours will be removed from the output contours based on their short length.

Linear Unit
contour_smooth_tolerance
(Optional)

The smoothing tolerance to apply to the contour lines after they are created. The larger the value, the more generalized the contours will be. The default value is set by the chosen scale. If the value is set to 0 or left blank, no smoothing will be applied to the output contours.

Linear Unit

Derived Output

NameExplanationData Type
updated_contour_features

The output generated when features are added to Target Contour Features.

Feature Layer

Code sample

GenerateTopographicContours example 1 (stand-alone script)

The following stand-alone sample script demonstrates how to run GenerateTopographicContours accepting all the default parameters that are set when you choose a scale tool.

# Name: GenerateTopographicContours_sample1.py
# Description: The Generate Topographic Contours tool creates contours that are
# appropriate for a cartographic product at a chosen scale. The following
# sample script demonstrates how to use Generate Topographic Contours to create
# contours appropriate for a 1:50,000 scale product using all the default values
# defined by the tool.

# Import System Modules
import arcpy

# Check Out Extensions
arcpy.CheckOutExtension('foundation')
arcpy.CheckOutExtension('spatial')

# Setting Local Variables
in_raster = r'C:\Data\Monterey.dt2'
aoi_fc = r'C:\Data\MapIndex.gdb\MapIndex\TLM50_Index'
contour_features = r'C:\Data\MGCP_TRD_4_4.gdb\MGCP_Delta\ContourL'
contour_subtype = 'CA010_Elevation_Contour_Line'
elevation_field = 'Highest Elevation'

# Create feature layer for area of interest and select a single feature based on the NRN field
aoi_layer = arcpy.MakeFeatureLayer_management(aoi_fc, 'aoi_layer')
arcpy.SelectLayerByAttribute_management(aoi_layer, 'NEW_SELECTION', "NRN = 'V795X16573'")

# Calling Generate Topographic Contours to create contours
arcpy.GenerateTopographicContours_topographic(in_raster, aoi_layer, contour_features, elevation_field, contour_subtype)

# Check In Extensions
arcpy.CheckInExtension('foundation')
arcpy.CheckInExtension('spatial')
GenerateTopographicContours example 2 (stand-alone script)

The following stand-alone sample script demonstrates how to use GenerateTopographicContours to override the default values.

# Name: GenerateTopographicContours_sample2.py
# Description: The Generate Topographic Contours tool creates contours that are
# appropriate for a cartographic product at a chosen scale. The following
# sample script demonstrates how to use Generate Topographic Contours to create
# contours appropriate for a 1:24,000 scale product using the 1:25,000 map
# scale value and overriding some of the default values.

# Import System Modules
import arcpy

# Check Out Extensions
arcpy.CheckOutExtension('foundation')
arcpy.CheckOutExtension('spatial')

# Set Local Variables
in_raster = r'C:\Data\Monterey.dt2'
aoi_fc = r'C:\Data\MapIndex.gdb\TOPO24K'
contour_features = r'C:\Data\Topo.gdb\Elev_Contour'
contour_subtype = '#'
elevation_field = 'ContourElevation'
scale = '1:25,000'
resample = 'RESAMPLE_RASTER'

# Default value for 1:25,000 scale is 10 m contours, change to 20 ft
contour_interval = 20
base_contour = 0

# Raster elevation is in meters, apply z_factor to get elevation in feet
z_factor = 3.2808
include_zero = 'ZERO_CONTOUR'

# Define the contour code field and values
code_field = 'FCODE'
index_interval = 100
index_code = '10102'
intermediate_code = '10101'
depression_code = '10105'
depression_intermediate_code = '10104'

# Adjust contour refinement values
raster_smooth = 0.2
minimum_length = '100 Feet'
contour_smooth = '25 Feet'

# Create feature layer for area of interest and select a single feature based on the Quad_Name field
aoi_layer = arcpy.MakeFeatureLayer_management(aoi_fc, 'aoi_layer')
arcpy.SelectLayerByAttribute_management(aoi_layer, 'NEW_SELECTION', "QUAD_NAME = 'Big Sur'")

# Call Generate Topographic Contours to create contours
arcpy.GenerateTopographicContours_topographic(in_raster, aoi_layer, contour_features, elevation_field, contour_subtype, 
                                              scale, resample, contour_interval, base_contour, z_factor, include_zero, 
                                              code_field, index_interval, index_code, intermediate_code, depression_code, 
                                              depression_intermediate_code, raster_smooth, minimum_length, contour_smooth)

# Check In Extensions
arcpy.CheckInExtension('foundation')
arcpy.CheckInExtension('spatial')

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: No
  • Advanced: Requires Production Mapping and ArcGIS Spatial Analyst extension

Related topics