.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "GDAL_CONTOUR" "1" "Sep 04, 2025" "" "GDAL" .SH NAME gdal_contour \- Builds vector contour lines from a raster elevation model. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX gdal_contour [\-\-help] [\-\-help\-general] [\-b ] [\-a ] [\-amin ] [\-amax ] [\-3d] [\-inodata] [\-snodata ] [\-f ] [\-i ] [\-dsco =]... [\-lco =]... [\-off ] [\-fl ...] [\-e ] [\-nln ] [\-q] [\-p] [\-gt |unlimited] .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp The \fBgdal_contour\fP generates a vector contour file from the input raster elevation model (DEM). .sp The contour line\-strings are oriented consistently and the high side will be on the right, i.e. a line string goes clockwise around a top. .INDENT 0.0 .TP .B \-\-help Show this help message and exit .UNINDENT .INDENT 0.0 .TP .B \-\-help\-general Gives a brief usage message for the generic GDAL commandline options and exit. .UNINDENT .INDENT 0.0 .TP .B \-b Picks a particular band to get the DEM from. Defaults to band 1. .UNINDENT .INDENT 0.0 .TP .B \-a Provides a name for the attribute in which to put the elevation. If not provided no elevation attribute is attached. Ignored in polygonal contouring (\fI\%\-p\fP) mode. .UNINDENT .INDENT 0.0 .TP .B \-amin Provides a name for the attribute in which to put the minimum elevation of contour polygon. If not provided no minimum elevation attribute is attached. Ignored in default line contouring mode. .sp Added in version 2.4.0. .UNINDENT .INDENT 0.0 .TP .B \-amax Provides a name for the attribute in which to put the maximum elevation of contour polygon. If not provided no maximum elevation attribute is attached. Ignored in default line contouring mode. .sp Added in version 2.4.0. .UNINDENT .INDENT 0.0 .TP .B \-3d Force production of 3D vectors instead of 2D. Includes elevation at every vertex. .UNINDENT .INDENT 0.0 .TP .B \-inodata Ignore any nodata value implied in the dataset \- treat all values as valid. .UNINDENT .INDENT 0.0 .TP .B \-snodata Input pixel value to treat as \(dqnodata\(dq. .UNINDENT .INDENT 0.0 .TP .B \-f Create output in a particular format. .sp Added in version 2.3.0: If not specified, the format is guessed from the extension (previously was ESRI Shapefile). .UNINDENT .INDENT 0.0 .TP .B \-dsco = Dataset creation option (format specific) .UNINDENT .INDENT 0.0 .TP .B \-lco = Layer creation option (format specific) .UNINDENT .INDENT 0.0 .TP .B \-i Elevation interval between contours. Must specify either \fI\%\-i\fP or \fI\%\-fl\fP or \fI\%\-e\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-off Offset from zero relative to which to interpret intervals. .sp For example, \fI\-i 100\fP requests contours at ...\-100, 0, 100... Further adding \fI\-off 25\fP makes that request instead ...\-75, 25, 125... .UNINDENT .INDENT 0.0 .TP .B \-fl Name one or more \(dqfixed levels\(dq to extract, in ascending order separated by spaces. .UNINDENT .INDENT 0.0 .TP .B \-e Generate levels on an exponential scale: \fIbase ^ k\fP, for \fIk\fP an integer. Must specify either \-i or \-fl or \-e. .sp Added in version 2.4.0. .UNINDENT .INDENT 0.0 .TP .B \-nln Provide a name for the output vector layer. Defaults to \(dqcontour\(dq. .UNINDENT .INDENT 0.0 .TP .B \-p Generate contour polygons rather than contour lines. .sp When this mode is selected the polygons are created for values between each level specified by \fI\%\-i\fP or \fI\%\-fl\fP or \fI\%\-e\fP, in case \fI\%\-fl\fP is used alone at least two fixed levels must be specified. .sp The minimum and maximum values from the raster are not automatically added to the fixed levels list but the special values \fIMIN\(ga\fP and \fIMAX\(ga\fP (case insensitive) can be used to include them. .sp Added in version 2.4.0. .UNINDENT .INDENT 0.0 .TP .B \-gt Group n features per transaction (default 100 000). Increase the value for better performance when writing into DBMS drivers that have transaction support. \fBn\fP can be set to unlimited to load the data into a single transaction. If set to 0, no explicit transaction is done. .sp Added in version 3.10. .UNINDENT .INDENT 0.0 .TP .B \-q Be quiet: do not print progress indicators. .UNINDENT .SH C API .sp Functionality of this utility can be done from C with \fI\%GDALContourGenerate()\fP\&. .SH EXAMPLES .SS Example 1 .INDENT 0.0 .TP .B title Creating contours from a DEM .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX gdal_contour \-a elev dem.tif contour.shp \-i 10.0 .EE .UNINDENT .UNINDENT .sp This would create 10\-meter contours from the DEM data in \fBdem.tif\fP and produce a shapefile in \fBcontour.shp|shx|dbf\fP with the contour elevations in the \fBelev\fP attribute. .SS Example 2 .INDENT 0.0 .TP .B title Creating polygonal contours from a DEM .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ cat test.asc ncols 2 nrows 2 xllcorner 0 yllcorner 0 cellsize 1 4 15 25 36 $ gdal_contour test.asc \-f GeoJSON /vsistdout/ \-i 10 \-p \-amin min \-amax max .EE .UNINDENT .UNINDENT .sp This would create 10\-meter polygonal contours from the DEM data in \fBtest.asc\fP and produce a GeoJSON output with the contour min and max elevations in the \fBmin\fP and \fBmax\fP attributes, including the minimum and maximum values from the raster. .INDENT 0.0 .INDENT 3.5 .sp .EX { \(dqtype\(dq: \(dqFeatureCollection\(dq, \(dqname\(dq: \(dqcontour\(dq, \(dqfeatures\(dq: [ { \(dqtype\(dq: \(dqFeature\(dq, \(dqproperties\(dq: { \(dqID\(dq: 0, \(dqmin\(dq: 4.0, \(dqmax\(dq: 10.0 }, \(dqgeometry\(dq: { \(dqtype\(dq: \(dqMultiPolygon\(dq, \(dqcoordinates\(dq: [ [ [ [ 0.5, 1.214285714285714 ], [ 1.045454545454545, 1.5 ], [ 1.045454545454545, 2.0 ], [ 1.0, 2.0 ], [ 0.5, 2.0 ], [ 0.0, 2.0 ], [ 0.0, 1.5 ], [ 0.0, 1.214285714285714 ], [ 0.5, 1.214285714285714 ] ] ] ] } }, { \(dqtype\(dq: \(dqFeature\(dq, \(dqproperties\(dq: { \(dqID\(dq: 1, \(dqmin\(dq: 10.0, \(dqmax\(dq: 20.0 }, \(dqgeometry\(dq: { \(dqtype\(dq: \(dqMultiPolygon\(dq, \(dqcoordinates\(dq: [ [ [ [ 1.5, 1.261904761904762 ], [ 2.0, 1.261904761904762 ], [ 2.0, 1.5 ], [ 2.0, 2.0 ], [ 1.5, 2.0 ], [ 1.045454545454545, 2.0 ], [ 1.045454545454545, 1.5 ], [ 0.5, 1.214285714285714 ], [ 0.0, 1.214285714285714 ], [ 0.0, 1.0 ], [ 0.0, 0.738095238095238 ], [ 0.5, 0.738095238095238 ], [ 1.5, 1.261904761904762 ] ] ] ] } }, { \(dqtype\(dq: \(dqFeature\(dq, \(dqproperties\(dq: { \(dqID\(dq: 2, \(dqmin\(dq: 20.0, \(dqmax\(dq: 30.0 }, \(dqgeometry\(dq: { \(dqtype\(dq: \(dqMultiPolygon\(dq, \(dqcoordinates\(dq: [ [ [ [ 0.954545454545455, 0.0 ], [ 0.954545454545455, 0.5 ], [ 1.5, 0.785714285714286 ], [ 2.0, 0.785714285714286 ], [ 2.0, 1.0 ], [ 2.0, 1.261904761904762 ], [ 1.5, 1.261904761904762 ], [ 0.5, 0.738095238095238 ], [ 0.0, 0.738095238095238 ], [ 0.0, 0.5 ], [ 0.0, 0.0 ], [ 0.5, 0.0 ], [ 0.954545454545455, 0.0 ] ] ] ] } }, { \(dqtype\(dq: \(dqFeature\(dq, \(dqproperties\(dq: { \(dqID\(dq: 3, \(dqmin\(dq: 30.0, \(dqmax\(dq: 36.0 }, \(dqgeometry\(dq: { \(dqtype\(dq: \(dqMultiPolygon\(dq, \(dqcoordinates\(dq: [ [ [ [ 1.499999909090926, 0.0 ], [ 1.0, 0.0 ], [ 0.954545454545455, 0.0 ], [ 0.954545454545455, 0.5 ], [ 1.5, 0.785714285714286 ], [ 2.0, 0.785714285714286 ], [ 2.0, 0.500000047619043 ], [ 1.5, 0.500000047619043 ], [ 1.499999909090926, 0.5 ], [ 1.499999909090926, 0.0 ] ] ] ] } } ] } .EE .UNINDENT .UNINDENT .SS Example 3 .INDENT 0.0 .TP .B title Creating contours from a DEM with fixed levels .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ cat test.asc ncols 2 nrows 2 xllcorner 0 yllcorner 0 cellsize 1 4 15 25 36 $ gdal_contour test.asc \-f GeoJSON /vsistdout/ \-fl 10 20 \-p \-amin min \-amax max .EE .UNINDENT .UNINDENT .sp This would create a single polygonal contour between 10 and 20 meters from the DEM data in \fBtest.asc\fP and produce a GeoJSON output with the contour min and max elevations in the \fBmin\fP and \fBmax\fP attributes. .sp If the minimum and maximum values from the raster are desired, the special values \fIMIN\(ga\fP and \fIMAX\(ga\fP (case insensitive) can be used: .INDENT 0.0 .INDENT 3.5 .sp .EX $ cat test.asc ncols 2 nrows 2 xllcorner 0 yllcorner 0 cellsize 1 4 15 25 36 $ gdal_contour test.asc \-f GeoJSON /vsistdout/ \-fl MIN 10 20 MAX \-p \-amin min \-amax max .EE .UNINDENT .UNINDENT .sp This would create three polygonal contours from the DEM data in \fBtest.asc\fP and produce a GeoJSON output with the contour min and max elevations in the \fBmin\fP and \fBmax\fP attributes, the values of these fields will be: (4.0, 10.0), (10, 20.0) and (20.0, 36.0). .SS Example 4 .INDENT 0.0 .TP .B title Creating contours from a DEM specifying an interval and fixed levels at the same time .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .EX $ cat test.asc ncols 2 nrows 2 xllcorner 0 yllcorner 0 cellsize 1 4 15 25 36 $ gdal_contour test.asc \-f GeoJSON /vsistdout/ \-i 10 \-fl 15 \-p \-amin min \-amax max .EE .UNINDENT .UNINDENT .sp Creates contours at regular 10 meter intervals and adds extra contour for a fixed 15 m level. Finally turns areas between the contours into polygons with the contour min and max elevations in the \fBmin\fP and \fBmax\fP attributes, the values of these fields will be: (4.0, 10.0), (10, 15.0), (15, 20.0), (20.0, 30.0) and (30.0, 36.0). .SH AUTHOR Frank Warmerdam , Silke Reimer .SH COPYRIGHT 1998-2025 .\" Generated by docutils manpage writer. .