Computerized Contour Mapping

By Darrel Dunn, Ph.D., Hydrogeologist - Geologist  

(View Résumé 🔳)

Purpose - Describe computerized contouring methods

The purpose of this web page is to describe two computerized contouring methods that are compatible with the FloPy module that develops MODFLOW input files.  The contouring methods could also be used to produce maps for petroleum exploration and production applications, or the analysis of any areally distributed data.  The contouring methods are (1) gridded averaging, and (2) Matplotlib linear interpolation on a triangular grid (matlotlib.tri.LinearTriInterpolator).  This page is technical and assumes the reader is familiar with Python and MODFLOW.  

Gridded averaging contouring method

The gridded averaging contouring method has not been described previously.  The method uses a set of Python programs that  I developed.  The programs produce an array of values for cells on a gridded map.  Known values (constants) are assigned to grid cells according to their locations, and values are calculated for the remaining cells.  The calculated values are the average of the values in the immediately adjacent cells.  If the grid used in a MODFLOW model is also used for the contouring, then a Python NumPy array is produced that can be used directly as input to FloPy.  One of the programs produces a grid plot of the constant and calculated values and another produces a contour map.  The gridded averaging method is capable of introducing directional trend to the contours by using weighted averaging.  Introducing trend might be useful in some geologic mapping where trends are known to exist.  Since NumPy arrays are involved, there is also an opportunity to manipulate the arrays before contouring.  Gridded averaging could be extended to three-dimensional interpolation.

The plotting and contouring method involves the following steps:

The scripts final_plot.py and array_contour.py each import variables from fdcontour.py.  The fdcontour.py script is shown in Attachment 4.  The fdcontour.py program calculates the values in the cells that do not contain constants as the average value of the immediately adjacent cells.  This is accomplished by solving the set of equations for average cell value simultaneously using successive overrelaxation (SOR).

Figure 1 shows the NumPy array produced for a simple artificial example of the method.  In this example the array shape is 5X5.  A constant value of 10 is assigned to the center cell, and constant values of 5 are assigned to corner cells and cells in the middle of each side of the grid.  Figure 2 shows the plot of the array, and Figure 3 shows a contour map of the array.  Inspection of Figure 1 shows that computed values in interior cells are indeed the average of the four surrounding cells.  Computed values of cells along the sides of the grid are the average of the three adjacent cells.  It is not necessary to put constants in the corner cells.  When corner cells are computed values, they are the average of the two adjacent cells.  Figure 2 is a plot of the values in Figure 1.  Figure 3 is a contour map of the array in Figure 1 produced by the contour function of Matplotlib.