Example 9 - Faulted Layers#

This example will show how to convert the geological map below using GemGIS to a GemPy model. This example is based on digitized data. The area is 2977 m wide (W-E extent) and 3731 m high (N-S extent). The vertical model extent varies from 0 m to 1000 m. The model represents two faulted layers (green and red) above a yellow basement. The map has been georeferenced with QGIS. The stratigraphic boundaries were digitized in QGIS. Strikes lines were digitized in QGIS as well and will be used to calculate orientations for the GemPy model. The contour lines were also digitized and will be interpolated with GemGIS to create a topography for the model.

Map Source: An Introduction to Geological Structures and Maps by G.M. Bennison

[1]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/cover_example09.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example09_2_0.png

Licensing#

Computational Geosciences and Reservoir Engineering, RWTH Aachen University, Authors: Alexander Juestel. For more information contact: alexander.juestel(at)rwth-aachen.de

This work is licensed under a Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/)

Import GemGIS#

If you have installed GemGIS via pip and conda, you can import GemGIS like any other package. If you have downloaded the repository, append the path to the directory where the GemGIS repository is stored and then import GemGIS.

[2]:
import warnings
warnings.filterwarnings("ignore")
import gemgis as gg

Importing Libraries and loading Data#

All remaining packages can be loaded in order to prepare the data and to construct the model. The example data is downloaded from an external server using pooch. It will be stored in a data folder in the same directory where this notebook is stored.

[3]:
import geopandas as gpd
import rasterio
[4]:
file_path = 'data/example09/'
gg.download_gemgis_data.download_tutorial_data(filename="example09_faulted_layers.zip", dirpath=file_path)
Downloading file 'example09_faulted_layers.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2Fexample09_faulted_layers.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\example\data\example09'.

Creating Digital Elevation Model from Contour Lines#

The digital elevation model (DEM) will be created by interpolating contour lines digitized from the georeferenced map using the SciPy Radial Basis Function interpolation wrapped in GemGIS. The respective function used for that is gg.vector.interpolate_raster().

[5]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/dem_example09.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example09_10_0.png
[6]:
topo = gpd.read_file(file_path + 'topo9.shp')
topo.head()
[6]:
id Z geometry
0 None 200 LINESTRING (867.721 3.054, 905.213 37.662, 962...
1 None 300 LINESTRING (180.750 7.091, 266.116 75.731, 321...
2 None 400 LINESTRING (3.094 646.765, 63.082 692.332, 171...
3 None 500 LINESTRING (3.671 1124.357, 90.768 1186.652, 2...
4 None 600 LINESTRING (4.825 1626.175, 82.693 1677.510, 1...

Interpolating the contour lines#

[7]:
topo_raster = gg.vector.interpolate_raster(gdf=topo, value='Z', method='rbf', res=10)

Plotting the raster#

[8]:
import matplotlib.pyplot as plt

fix, ax = plt.subplots(1, figsize=(10, 10))
topo.plot(ax=ax, aspect='equal', column='Z', cmap='gist_earth')
im = plt.imshow(topo_raster, origin='lower', extent=[0, 2977, 0, 3731], cmap='gist_earth')
cbar = plt.colorbar(im)
cbar.set_label('Altitude [m]')
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2977)
ax.set_ylim(0, 3731)
[8]:
(0.0, 3731.0)
../../_images/getting_started_example_example09_15_1.png

Saving the raster to disc#

After the interpolation of the contour lines, the raster is saved to disc using gg.raster.save_as_tiff(). The function will not be executed as a raster is already provided with the example data.

gg.raster.save_as_tiff(raster=topo_raster, path=file_path + 'raster9.tif', extent=[0, 2977, 0, 3731], crs='EPSG:4326', overwrite_file=True)

Opening Raster#

The previously computed and saved raster can now be opened using rasterio.

[9]:
topo_raster = rasterio.open(file_path + 'raster9.tif')

Interface Points of stratigraphic boundaries#

The interface points will be extracted from LineStrings digitized from the georeferenced map using QGIS. It is important to provide a formation name for each layer boundary. The vertical position of the interface point will be extracted from the digital elevation model using the GemGIS function gg.vector.extract_xyz(). The resulting GeoDataFrame now contains single points including the information about the respective formation.

[10]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/interfaces_example09.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example09_21_0.png
[11]:
interfaces = gpd.read_file(file_path + 'interfaces9.shp')
interfaces.head()
[11]:
id formation geometry
0 None A LINESTRING (4.825 1655.015, 134.029 1510.814, ...
1 None B LINESTRING (573.552 2032.244, 637.000 1868.432...
2 None A LINESTRING (3.671 2628.080, 119.032 2559.441, ...
3 None B LINESTRING (6.555 3203.152, 225.740 3105.672, ...
4 None B LINESTRING (1979.796 1736.344, 1999.407 1814.7...

Extracting Z coordinate from Digital Elevation Model#

[12]:
interfaces_coords = gg.vector.extract_xyz(gdf=interfaces, dem=topo_raster)
interfaces_coords = interfaces_coords.sort_values(by='formation', ascending=False)
interfaces_coords.head()
[12]:
formation geometry X Y Z
95 F POINT (2973.626 1660.206) 2973.63 1660.21 612.70
87 F POINT (1734.655 1726.538) 1734.65 1726.54 351.47
79 F POINT (4.825 2222.588) 4.82 2222.59 741.10
80 F POINT (397.627 2107.228) 397.63 2107.23 655.76
81 F POINT (631.809 2029.936) 631.81 2029.94 577.42

Plotting the Interface Points#

[13]:
fig, ax = plt.subplots(1, figsize=(10, 10))

interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')
interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')
plt.grid()
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2977)
ax.set_ylim(0, 3731)
[13]:
(0.0, 3731.0)
../../_images/getting_started_example_example09_26_1.png

Orientations from Strike Lines#

Strike lines connect outcropping stratigraphic boundaries (interfaces) of the same altitude. In other words: the intersections between topographic contours and stratigraphic boundaries at the surface. The height difference and the horizontal difference between two digitized lines is used to calculate the dip and azimuth and hence an orientation that is necessary for GemPy. In order to calculate the orientations, each set of strikes lines/LineStrings for one formation must be given an id number next to the altitude of the strike line. The id field is already predefined in QGIS. The strike line with the lowest altitude gets the id number 1, the strike line with the highest altitude the the number according to the number of digitized strike lines. It is currently recommended to use one set of strike lines for each structural element of one formation as illustrated.

[14]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/orientations_example09.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example09_28_0.png
[15]:
strikes = gpd.read_file(file_path + 'strikes9.shp')
strikes.head()
[15]:
id formation Z geometry
0 1 F 400 LINESTRING (1196.498 1839.015, 1975.758 1721.924)
1 2 F 500 LINESTRING (863.107 1948.030, 2263.005 1724.231)
2 3 F 600 LINESTRING (570.091 2050.413, 2855.670 1673.473)
3 4 F 700 LINESTRING (235.257 2155.391, 2973.914 1720.194)
4 1 A 200 LINESTRING (1210.630 428.734, 2123.419 273.285)

Calculate Orientations for each formation#

[16]:
orientations_f = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'F'].sort_values(by='Z', ascending=True).reset_index())
orientations_f
[16]:
dip azimuth Z geometry polarity formation X Y
0 64.53 188.96 450.00 POINT (1574.592 1808.300) 1.00 F 1574.59 1808.30
1 65.13 189.29 550.00 POINT (1637.968 1849.037) 1.00 F 1637.97 1849.04
2 62.92 189.17 650.00 POINT (1658.733 1899.867) 1.00 F 1658.73 1899.87
[17]:
orientations_a = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'A'].sort_values(by='Z', ascending=True).reset_index())
orientations_a
[17]:
dip azimuth Z geometry polarity formation X Y
0 22.42 189.39 250.00 POINT (1722.398 466.081) 1.00 A 1722.40 466.08
1 22.33 189.31 350.00 POINT (1758.376 707.978) 1.00 A 1758.38 707.98
2 21.48 189.15 450.00 POINT (1681.589 975.542) 1.00 A 1681.59 975.54
3 21.43 189.10 550.00 POINT (1558.442 1257.310) 1.00 A 1558.44 1257.31
[18]:
orientations_a1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'A1'].sort_values(by='Z', ascending=True).reset_index())
orientations_a1
[18]:
dip azimuth Z geometry polarity formation X Y
0 22.20 189.33 750.00 POINT (1228.511 2222.011) 1.00 A1 1228.51 2222.01
[19]:
orientations_b = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B'].sort_values(by='Z', ascending=True).reset_index())
orientations_b
[19]:
dip azimuth Z geometry polarity formation X Y
0 21.25 189.23 350.00 POINT (1589.589 1252.119) 1.00 B 1589.59 1252.12
1 23.14 189.46 450.00 POINT (1591.463 1503.028) 1.00 B 1591.46 1503.03
[20]:
orientations_b1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B1'].sort_values(by='Z', ascending=True).reset_index())
orientations_b1
[20]:
dip azimuth Z geometry polarity formation X Y
0 22.28 189.22 450.00 POINT (1590.166 1911.692) 1.00 B1 1590.17 1911.69
1 22.28 189.36 550.00 POINT (1620.159 2159.140) 1.00 B1 1620.16 2159.14
2 22.54 189.09 650.00 POINT (1676.686 2398.513) 1.00 B1 1676.69 2398.51
3 22.20 189.22 750.00 POINT (1657.651 2651.729) 1.00 B1 1657.65 2651.73

Merging Orientations#

[21]:
import pandas as pd
orientations = pd.concat([orientations_f, orientations_a, orientations_a1, orientations_b, orientations_b1]).reset_index()
orientations['formation'] = ['F', 'F', 'F', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B']
orientations = orientations[orientations['formation'].isin(['F', 'A', 'B'])]
orientations
[21]:
index dip azimuth Z geometry polarity formation X Y
0 0 64.53 188.96 450.00 POINT (1574.592 1808.300) 1.00 F 1574.59 1808.30
1 1 65.13 189.29 550.00 POINT (1637.968 1849.037) 1.00 F 1637.97 1849.04
2 2 62.92 189.17 650.00 POINT (1658.733 1899.867) 1.00 F 1658.73 1899.87
3 0 22.42 189.39 250.00 POINT (1722.398 466.081) 1.00 A 1722.40 466.08
4 1 22.33 189.31 350.00 POINT (1758.376 707.978) 1.00 A 1758.38 707.98
5 2 21.48 189.15 450.00 POINT (1681.589 975.542) 1.00 A 1681.59 975.54
6 3 21.43 189.10 550.00 POINT (1558.442 1257.310) 1.00 A 1558.44 1257.31
7 0 22.20 189.33 750.00 POINT (1228.511 2222.011) 1.00 A 1228.51 2222.01
8 0 21.25 189.23 350.00 POINT (1589.589 1252.119) 1.00 B 1589.59 1252.12
9 1 23.14 189.46 450.00 POINT (1591.463 1503.028) 1.00 B 1591.46 1503.03
10 0 22.28 189.22 450.00 POINT (1590.166 1911.692) 1.00 B 1590.17 1911.69
11 1 22.28 189.36 550.00 POINT (1620.159 2159.140) 1.00 B 1620.16 2159.14
12 2 22.54 189.09 650.00 POINT (1676.686 2398.513) 1.00 B 1676.69 2398.51
13 3 22.20 189.22 750.00 POINT (1657.651 2651.729) 1.00 B 1657.65 2651.73

Plotting the Orientations#

[22]:
fig, ax = plt.subplots(1, figsize=(10, 10))

interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')
interfaces_coords.plot(ax=ax, column='formation', legend=True, aspect='equal')
orientations.plot(ax=ax, color='red', aspect='equal')
plt.grid()
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 2977)
ax.set_ylim(0, 3731)
[22]:
(0.0, 3731.0)
../../_images/getting_started_example_example09_39_1.png

GemPy Model Construction#

The structural geological model will be constructed using the GemPy package.

[23]:
import gempy as gp
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

Creating new Model#

[24]:
geo_model = gp.create_model('Model9')
geo_model
[24]:
Model9  2022-04-05 10:00

Initiate Data#

[25]:
gp.init_data(geo_model, [0, 2977, 0, 3731, 0, 1000], [100, 100, 100],
             surface_points_df=interfaces_coords[interfaces_coords['Z'] != 0],
             orientations_df=orientations,
             default_values=True)
Active grids: ['regular']
[25]:
Model9  2022-04-05 10:00

Model Surfaces#

[26]:
geo_model.surfaces
[26]:
surface series order_surfaces color id
0 F Default series 1 #015482 1
1 B Default series 2 #9f0052 2
2 A Default series 3 #ffbe00 3

Mapping the Stack to Surfaces#

[27]:
gp.map_stack_to_surfaces(geo_model,
                         {
                          'Fault1': ('F'),
                          'Strata1': ('B', 'A'),
                         },
                         remove_unused_series=True)
geo_model.add_surfaces('C')
geo_model.set_is_fault(['Fault1'])
Fault colors changed. If you do not like this behavior, set change_color to False.
[27]:
order_series BottomRelation isActive isFault isFinite
Fault1 1 Fault True True False
Strata1 2 Erosion True False False

Showing the Number of Data Points#

[28]:
gg.utils.show_number_of_data_points(geo_model=geo_model)
[28]:
surface series order_surfaces color id No. of Interfaces No. of Orientations
0 F Fault1 1 #527682 1 17 3
1 B Strata1 1 #9f0052 2 49 6
2 A Strata1 2 #ffbe00 3 30 5
3 C Strata1 3 #728f02 4 0 0

Loading Digital Elevation Model#

[29]:
geo_model.set_topography(
    source='gdal', filepath=file_path + 'raster9.tif')
Cropped raster to geo_model.grid.extent.
depending on the size of the raster, this can take a while...
storing converted file...
Active grids: ['regular' 'topography']
[29]:
Grid Object. Values:
array([[  14.885     ,   18.655     ,    5.        ],
       [  14.885     ,   18.655     ,   15.        ],
       [  14.885     ,   18.655     ,   25.        ],
       ...,
       [2972.00503356, 3705.99329759,  772.98675537],
       [2972.00503356, 3715.99597855,  772.22625732],
       [2972.00503356, 3725.99865952,  771.48016357]])

Plotting Input Data#

[30]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
../../_images/getting_started_example_example09_55_0.png
[31]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
../../_images/getting_started_example_example09_56_0.png
[31]:
<gempy.plot.vista.GemPyToVista at 0x2a531e26640>

Setting the Interpolator#

[32]:
gp.set_interpolator(geo_model,
                    compile_theano=True,
                    theano_optimizer='fast_compile',
                    verbose=[],
                    update_kriging=False
                    )
Compiling theano function...
Level of Optimization:  fast_compile
Device:  cpu
Precision:  float64
Number of faults:  1
Compilation Done!
Kriging values:
                    values
range             4876.77
$C_o$           566259.29
drift equations    [3, 3]
[32]:
<gempy.core.interpolator.InterpolatorModel at 0x2a52bddbbb0>

Computing Model#

[33]:
sol = gp.compute_model(geo_model, compute_mesh=True)

Plotting Cross Sections#

[34]:
gp.plot_2d(geo_model, direction=['x', 'x', 'y', 'y'], cell_number=[25, 75, 25, 75], show_topography=True, show_data=False)
[34]:
<gempy.plot.visualization_2d.Plot2D at 0x2a52f05da90>
../../_images/getting_started_example_example09_62_1.png

Plotting 3D Model#

[35]:
gpv = gp.plot_3d(geo_model, image=False, show_topography=True,
                 plotter_type='basic', notebook=True, show_lith=True)
../../_images/getting_started_example_example09_64_0.png
[ ]: