Now let's look at another way to better visualize elevation using contours. A contour is an isoline along the same elevation in a data set. Contours are usually stepped at intervals to create an intuitive way to represent elevation data, both visually and numerically, using a resource efficient vector data set.
The input for generating contours is our DEM and the output is a shapefile. The algorithm for generating contours is fairly complex and very difficult to implement using NumPy's linear algebra. So our solution in this case is to fall back on the GDAL library, which has a contouring method available through the Python API. In fact, the majority of this script is just setting up the OGR library code needed to output shapefile. The actual contouring is a single method call named
. Just before that call, there are comments defining the method's arguments. The most important ones are as follows:
contourInterval: It is the distance in data...