Geospatial Modelling Environment

contour (Contour)

Creates contours based on continuous raster data


This tool creates contours (lines) based on a raster dataset representing continuous data (e.g. a digital elevation model), and a set of user-defined levels representing the z-values at which to generate the contours. The output is a line (polyline) dataset, with the z-values for each contour line recorded in the attribute table.

This algorithm produces high-quality contour lines at the expense of processing time. It interprets the raster as a triangular regular network and performs a plane intersection to determine the paths of the contour lines. It does not perform any sort of smoothing on the line, which I have reservations about. I have not been able to test this algorithm widely, so if you are able to find degenerate examples where the algorithm performs poorly, I would be grateful to hear about them so that the algorithm can be improved.

Although a ‘band’ option is included so that users can identify which band to process in the case of multiband images, it is likely that this tool will most often be run with continuous, single-band raster data (like DEM’s).


contour(in, out, levels, [band]);

inthe input integer raster data source
outthe output line data source
levelsthe z-values at which to generate contours. e.g. 100 or c(10,20,30)
[band]the input band (default=1)


contour(in=”C:datadem”, out=”C:datacontours.shp”, levels=c(1000,2000,3000,4000,5000));

contour(in=”C:datadem”, out=”C:datacontours.shp”, levels=0.05);

contour(in=”C:datadem”, out=”C:datacontours.shp”, levels=r.eval(seq(100,10000,100)));


Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn