A Linux tool for calculating local best-fit plane attitudes from geological traces

The topographic traces of geological surfaces store information on the 3D attitudes of the geological surfaces. Knowing the coordinates of the intersection points between a topographic surface and a geological surface, it is therefore possible to estimate the local attitudes of a geological surface.

The tools

A short description of geoSurfDEM: it is composed of two tools, IntersectDEM and the new BestFitGeoplanes.
The former allows to calculate the intersection points between a geological surfaces (stored in the VTK format) and a DEM. The latter, that will be described in the current post, allows to estimate the local attitudes given a set of 3D points, all deriving from the intersection between a single geological surface and a topographic surface. BestFitGeoplanes is developed using C++ and Fortran. The algorithm uses Singular Value Decomposition (SVD) in order to invert the local traces into local best-fit planes. 

The input data is constituted by a set of points (their x, y and z coordinates), all related to a single, continuous geological surface. How to process them in order to derive the local attitudes? Since the source points are unconnected points (not lines), all deriving from a single, continuous surface, the 2D space is discretized into a raster, using a user-defined cell size.
Based on the points falling into a cell, we have three possible cases:
  1. no points falling into the cell;
  2. one or two points falling into the cell;
  3. three or more points in the cell.
In the first and second case, no attitude inversion via SVD is possible.
In the third case, when the points are not all collinear, a solution is provided by the SVD method. This solution is attributed to the grid cell.
The algorithm output will therefore consist in a gridded set of points for which the local attitudes have been inverted.
What is the difference with deriving the attitude via a spatial interpolation using for instance kriging? These interpolations implicitly assume a 2.5D surface and do not allow 3D surfaces. Geological surfaces, on the other hand, due to folding, can be 3D surfaces, i.e. with more then one point for each x-y position. Local inversion via SVD does not constrain the geological surfaces to be 2.5D,  but that may be locally modeled via a planar surface.


This application is developed in Linux and is available at: https://github.com/mauroalberti/geoSurfDEM.
A makefile is available for compiling this tool in a Linux environment.
The compilation sequence is:
cd path/to/source/files
make clean

Lapack and BLAS libraries must be available. The makefile assumes that Lapack is available in usr/lib/lapack (with name lapack) and BLAS in usr/lib/libblas (name blas). Modify the makefile accordingly, to adapt to your settings. Alternatively, an example of commands to build it (always in a Linux environment and with same libraries settings) is in https://github.com/mauroalberti/geoSurfDEM/blob/master/BestFitGeoplanes/compile


Having compiled the application, it is possible to run it as console application (Fig. 1). The only user interaction after launching the application is providing a parameter file name ("param.txt" in Fig. 1 example).

Fig. 1. Example of a run of the application.
The input parameter file is a text file that lists six pieces of information:
  1. the path of text file storing the 3D coordinates (x, y and z) of the intersection points of a single, continuous, geological surface;
  2. the number of header lines in the file referenced in point 1;
  3. the path  of the text file in which the georeferenced results will be stored;
  4. the path to the analysis report file;
  5. the path of the grid (in ESRI ASCII grid format) that will list the number of intersection points for each grid cell;
  6. the grid cell size;
 An example is available in https://github.com/mauroalberti/geoSurfDEM/tree/master/BestFitGeoplanes, in the param.txt file:


The application output is represented by the three files listed in points 3-5 of the previous list. The more important is the inverted result file (point # 3), that consists in a csv file listing a few fields (see Fig. 2):
  1. x: x coordinate of the cell grid center;
  2. y: y coordinate of the cell grid center;
  3. pt_num: number of points used for the inversion. Required minimum is 3.
  4. dip_dir: inverted dip direction for geoplane points in cell;
  5. dip_ang: inverted dip angle for geoplane points in cell;
  6. x_range: spatial range along the x-direction (E-W) for the inverted points in the considered cell;
  7. y_range: spatial range along the y-direction (N-S) for the inverted points in the considered cell;
  8. z_range: spatial range along the z-direction (vertical) for the inverted points in the considered cell;
  9. pseudo-volume: "pseudo"-volume defined by the inverted points in the cell, given by the product of the three previous ranges (i.e., x_range, y_range and z_range) - possibly removed in successive releases.
Fig. 2. Tabular view of the content of the inversion result file, as viewed by importing the file in QGIS.

A theoretical case study

This post presents a practical assessment of the result, by using a theoretical surface for which the expected local attitudes are known (currently, as of February 2017, all example data are available at https://github.com/mauroalberti/geoSurfDEM/tree/master/test_data).
A theoretical plane has been generated using simSurf, with dip direction equal to 135° and dip angle of 35°.
This plane, saved in VTK format from within simSurf, has been used as input plane to be intersecated with a natural topographic surface, of the Mt. Alpi zone (Lucania, Southern Italy), using the IntersectDEM of geoSurfDEM.
The resulting intersection points are saved as a csv file, that can be used as input for the BestFitGeoplanes. The intersection points, to be used for the best-fit-plane local inversions, are represented in Fig. 3.

Fig. 3. Input points (yellow) representing the theoretical intersection between a geoplane oriented 135°/35° (dip dir. and dip angle) and a DEM topography (Mt. Alpi zone, Lucania, Southern Italy). Visualization using QGIS.
Using BestFitGeoplanes with the previously described param.txt file, we obtain a result that, for the georeferenced point part, imported in QGIS is shown in Fig. 4.

Fig. 4. The same as in Fig. 3, plus superposed the gridded points with inverted results (orange dots). Visualization with QGIS.

How much the inverted results conform to the theoretical input source, that as said is a plane with a dip direction of 135° and a dip angle of 35°?
A stereoplot, created with the geocouche plugin for QGIS, illustrates the degree of  concordance between the source attitude (135°/35°, blue great circle in Fig. 5) and the inverted local attitudes (semi-transparent orange great circles in Fig. 5).
The majority of inverted data conform closely to the expected result, while a few inversions show a minor deviation from the expected result.
Fig. 5. Stereonet representing the inferred local plane attitudes as semi-opaque orange great circles, and the source geological plane attitude (135°/35°) as blue great circle. Created with geocouche.

The deviations of the inverted results from the expected value were calculated using the "Geological angles" of geocouche and the statistics calculated with QGIS (see Fig. 6). The maximum is 9.3° and the minimum almost zero, while the median and mean deviation values are lower than 0.5°. The standard deviation is about 1.2°. So in general we can be quite confident in the generated results. More in-depth analyses of the deviations of expected-versus-inferred results could be the subject of a still to-be-written paper.

Fig. 6. Statistics for angular deviations of the calculated results from the theoretical test case.