Contour with Barriers (Spatial Analyst)
Summary
Creates contours from a raster surface. The inclusion of barrier features will allow one to independently generate contours on either side of a barrier.
Usage
-
The current version of Contour with Barriers only supports polyline output. If the polygon output option is used it will be ignored and polyline output will be created.
-
Smoother but less accurate contours can be obtained by pre-processing the input raster with a Focal_Statistics operation with the MEAN option or the Filter tool with the LOW option.
-
Contours will extend into the raster's NoData cell by a distance of half the raster's cell size. This will mean that the contours will be generated over single NoData cells. However, a 3-cell-by-3-cell area of NoData will only have the contours extending into this area by half the cell size distance.
-
The Type field in the output contour feature class has values:
1 for contours 2 for indexed contours 3 for explicit contours
-
An indexed contour interval can be used to generate additional contours and their Type value will be coded as 2 in the output 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.
-
A text file containing contour value specifications can include the following:
- Any line that starts with a non-numeric value will be ignored and treated as a comment line.
- A line with a single value will be treated as an explicit contour value.
- A line with three values will be treated as base, contour interval, and indexed contour.
- A line with four values will treated as from, to, by, and indexed contours.
For example, if a raster has a minimum value of 102 and a maximum of 500, then a text file with:
# contour values and ranges 122.75 485 500 5 12 4 100 99
will produce contours at:
122.75 104, 204, 304, 404 103, 202, 301, 400, 499 485, 490, 495, 500 497
-
If there are cell values of the raster within a barrier polygon feature the contour lines will be split at the barrier. If the cell values within the polygon feature are to be ignored, change those cell values to NoData.
-
If the input raster surface is very large or many output features are requested, a large number of temporary files will be created in the operating system's temporary file location. If any problems are encountered as a result of this do one of the following:
- Increase the available disk space for temporary files.
- Reduce the number of contours specified, or split the contour range up and process each group separately, and combine the results from each range into a final result.
- Process the input data in sections (tiles), and merge the individual results into one dataset.
The output contour features can be labeled by using the Contour Annotation tool.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input surface raster. | Raster Layer |
out_contour_feature_class |
Output contour features. | Feature Class |
in_barrier_features (Optional) |
Input barrier features. | Feature Layer |
in_contour_type (Optional) |
The type of contour to create.
The current version of Contour with Barriers only supports polyline output. If the polygon output option is used it will be ignored and polyline output will be created. | String |
in_contour_values_file (Optional) |
The base contour, contour interval, indexed contour interval, and explicit contour values can also be specified via a text file. | File |
explicit_only (Optional) |
Only explicit contour values are used. Base contour, contour interval, and indexed contour intervals are not specified.
| Boolean |
in_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 |
in_contour_interval (Optional) |
Interval of contours. This can be any positive number. | Double |
in_indexed_contour_interval (Optional) |
Contours will also be generated for this interval and will be flagged accordingly in the output feature class. | Double |
in_contour_list [in_explicit_contour,...] (Optional) |
Explicit values at which to create contours. | Double |
in_z_factor (Optional) |
Multiplication factor. For example, if your z units are feet and your contours should be in 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 |
Code Sample
This example creates contours from an ESRI GRID raster with an input barrier feature as well as base and interval parameters specified. The output contours area as polylines in a shapefile.
import arcpy from arcpy import env from arcpy.sa import * env.workspace = "C:/sapyexamples/data" ContourWithBarriers("elevation", "C:/sapyexamples/output/outcontourwithbarriers.shp", "elevation_barrier.shp", "POLYLINES", "", "", 0, 300)
This example creates contours from an ESRI GRID raster with an input barrier feature as well as base and interval parameters specified. The output contours area as polylines in a shapefile.
# Name: ContourWithBarriers_Ex_02.py # Description: Creates contours from a raster surface. # The inclusion of barrier features will allow one to independently generate contours on either side of a barrier. # Requirements: Spatial Analyst Extension # Author: ESRI # Import system modules import arcpy from arcpy import env from arcpy.sa import * # Set environment settings env.workspace = "C:/sapyexamples/data" # Set local variables inRaster = "elevation" inBarrier = "elevation_barrier.shp" inTextFile = "" explicitValues = "NO_EXPLICIT_VALUES_ONLY" contourInterval = 200 contourList = [600, 935, 1237.4] baseContour = 0 outContours = "C:/sapyexamples/output/outcontourwithbarriers02.shp" # Check out the ArcGIS Spatial Analyst extension license arcpy.CheckOutExtension("Spatial") # Execute Contour ContourWithBarriers(inRaster, outContours, inBarrier, "POLYLINES", inTextFile, explicitValues, baseContour, contourInterval, "", contourList, "")