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 Map Scale parameter is used to refine the appearance of the contours to be optimized for print and display at the given scale. Choosing a scale sets the default contour values for several parameters based on the scale. The scale value also determines the minimum length of the contours and the smoothing tolerance used to refine their appearance. When the scale and any of the parameters that calculate their default values from it are left blank, the tool will use the 1:50,000 scale to calculate the values.
To clear contour values after they are automatically populated, choose the empty value at the top of the Map Scale drop-down list. Then choose the correct scale from the Map Scale parameter to repopulate the default contour values.
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; it 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 to that schema as a postprocess, this tool will add the results directly to the chosen feature class.
A base contour is used, for example, to create contours every 15 meters, starting at 10 meters. In this case, 10 is used for the base contour, and 15 is used for the contour interval. The values to be contoured are 10, 25, 40, and 55.
Specifying a base contour does not prevent contours from being created above or below that value.
In addition to the contour elevation, you can populate the Contour Code Field parameter with information about the type of contour. When a Contour Code Field is defined, use the following parameters to ensure that the field values are correctly populated:
- Contour Index Interval—Distinguish index contours from intermediate contours.
- Index Code—The value that will populate the Contour Code Field when the elevation of the contour is evenly divisible by the index interval and the contours are increasing in elevation.
- Intermediate Code—The value that will populate 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.
- Depression Code—The value that will populate the Contour Code Field when the elevation of the contour is evenly divisible by the index interval and the contours are decreasing in elevation.
- Depression Intermediate Code—The value that will populate 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 supports 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 parameter value 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 may have a coarse, blocky appearance. The Contour Smooth Tolerance parameter will apply a line smoothing algorithm to the contour lines to refine sharp angles and create smoother contours.
Syntax
GenerateTopographicContours(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})
Parameter | Explanation | Data 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 used to clip the input raster before processing. A buffer is created before clipping the raster, which 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) | The subtype to which contours will be written if the input contours have subtypes. | String |
scale (Optional) | Specifies the scale that will be used to optimize contours (the scale of the cartographic product that will be printed). Choosing the scale will set the defaults of other parameters to values that are appropriate for the output scale. The default value is the 1:50,000 cartographic product scale.
| String |
resample_raster (Optional) | Specifies whether the input raster will be resampled before 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 scale value. If this parameter is left blank, the default scale value will be used. | 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 unit other than that of the z-values, set an appropriate value for the z-factor. It is not necessary that 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 in meters, set the z-factor to 0.3048 (1 foot = 0.3048 meters). | Double |
zero_contour (Optional) | Specifies whether a zero contour will be created. 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 want contours generated on land areas that are at or below sea level.
| Boolean |
code_field (Optional) | The 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 want index contours every 100 meters, specify 100. The default is set by the scale value. | 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 to apply 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 scale value. 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 amount of smoothing to apply to the contour lines. The larger the value, the more generalized the contours. The default value is set by the scale value. If this parameter is set to 0 or left blank, no smoothing will be applied to the output contours. | Linear Unit |
Derived Output
Name | Explanation | Data Type |
updated_contour_features | The output generated when features are added to Target Contour Features. | Feature Layer |
Code sample
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')
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
Licensing information
- Basic: No
- Standard: No
- Advanced: Requires Production Mapping and ArcGIS Spatial Analyst extension