Example 6 - Folded Unconformable 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 4642 m wide (W-E extent) and 3519 m high (N-S extent). The vertical model extent varies from 0 m to 1500 m. The model represents folded layers (yellow to light green) which are separated to a second set of layers (blue and purple) by an unconformity. The light green layer also represents the 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_example06.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example06_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 or 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/example06/'
gg.download_gemgis_data.download_tutorial_data(filename="example06_folded_unconformable_layers.zip", dirpath=file_path)
Downloading file 'example06_folded_unconformable_layers.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2Fexample06_folded_unconformable_layers.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\example\data\example06'.

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_example06.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example06_10_0.png
[6]:
topo = gpd.read_file(file_path + 'topo6.shp')
topo.head()
[6]:
id Z geometry
0 None 1100 LINESTRING (1206.918 3514.485, 1274.374 3468.7...
1 None 1000 LINESTRING (3.594 3507.957, 151.562 3458.998, ...
2 None 900 LINESTRING (2.506 3289.270, 195.081 3252.278, ...
3 None 800 LINESTRING (4.682 3102.135, 143.946 3077.111, ...
4 None 1100 LINESTRING (4639.548 1815.034, 4610.172 1701.8...

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

from mpl_toolkits.axes_grid1 import make_axes_locatable
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, 4642, 0, 3519], cmap='gist_earth')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
cbar = plt.colorbar(im, cax=cax)
cbar.set_label('Altitude [m]')
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
ax.set_xlim(0, 4642)
ax.set_ylim(0, 3519)
[8]:
(0.0, 3519.0)
../../_images/getting_started_example_example06_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 + 'raster6.tif', extent=[0, 4642, 0, 3519], 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 + 'raster6.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_example06.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example06_21_0.png
[11]:
interfaces = gpd.read_file(file_path + 'interfaces6.shp')
interfaces.head()
[11]:
id formation geometry
0 None B LINESTRING (906.087 7.328, 949.607 50.304, 984...
1 None C LINESTRING (631.368 5.152, 704.264 75.871, 802...
2 None D LINESTRING (6.858 261.919, 85.194 305.439, 185...
3 None B LINESTRING (1097.031 2316.057, 1135.111 2310.6...
4 None C LINESTRING (1125.319 2522.776, 1202.566 2478.1...

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
453 Y POINT (4639.004 939.741) 4639.00 939.74 1040.37
411 Y POINT (1988.644 3097.783) 1988.64 3097.78 954.71
423 Y POINT (3972.606 2942.743) 3972.61 2942.74 928.61
422 Y POINT (3846.399 2956.887) 3846.40 2956.89 936.75
421 Y POINT (3713.663 2967.767) 3713.66 2967.77 938.66

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, 4642)
ax.set_ylim(0, 3519)
[13]:
(0.0, 3519.0)
../../_images/getting_started_example_example06_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_example06.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example06_28_0.png
[15]:
strikes = gpd.read_file(file_path + 'strikes6.shp')
strikes.head()
[15]:
id formation Z geometry
0 1 B 500 LINESTRING (1048.887 2285.049, 1046.711 1758.459)
1 2 B 500 LINESTRING (1196.855 2262.201, 1196.855 1875.962)
2 1 C1 500 LINESTRING (1529.782 2283.961, 1539.573 2067.450)
3 2 C 500 LINESTRING (685.496 2305.721, 697.464 1551.739)
4 1 C 400 LINESTRING (383.849 1996.186, 378.953 1721.467)

Calculate Orientations for each formation#

[16]:
orientations_b = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B'].sort_values(by='Z', ascending=True).reset_index())
orientations_b
[16]:
dip azimuth Z geometry polarity formation X Y
0 0.00 0.00 500.00 POINT (1122.327 2045.418) 1.00 B 1122.33 2045.42
[17]:
orientations_b1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'B1'].sort_values(by='Z', ascending=True).reset_index())
orientations_b1
[17]:
dip azimuth Z geometry polarity formation X Y
0 0.00 0.00 500.00 POINT (1123.143 973.537) 1.00 B1 1123.14 973.54
[18]:
orientations_c = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'C'].sort_values(by='Z', ascending=True).reset_index())
orientations_c
[18]:
dip azimuth Z geometry polarity formation X Y
0 18.07 269.32 450.00 POINT (536.440 1893.778) 1.00 C 536.44 1893.78
1 16.77 269.96 550.00 POINT (861.343 1916.762) 1.00 C 861.34 1916.76
[19]:
orientations_c1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'C1'].sort_values(by='Z', ascending=True).reset_index())
orientations_c1
[19]:
dip azimuth Z geometry polarity formation X Y
0 18.26 90.30 550.00 POINT (1379.502 2078.602) 1.00 C1 1379.50 2078.60
[20]:
orientations_c2 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'C1'].sort_values(by='Z', ascending=True).reset_index())
orientations_c2
[20]:
dip azimuth Z geometry polarity formation X Y
0 18.26 90.30 550.00 POINT (1379.502 2078.602) 1.00 C1 1379.50 2078.60
[21]:
orientations_d = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'D'].sort_values(by='Z', ascending=True).reset_index())
orientations_d
[21]:
dip azimuth Z geometry polarity formation X Y
0 17.00 270.73 650.00 POINT (211.673 1877.322) 1.00 D 211.67 1877.32
[22]:
orientations_d1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'D1'].sort_values(by='Z', ascending=True).reset_index())
orientations_d1
[22]:
dip azimuth Z geometry polarity formation X Y
0 16.79 268.97 650.00 POINT (212.217 684.878) 1.00 D1 212.22 684.88
[23]:
orientations_d2 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'D2'].sort_values(by='Z', ascending=True).reset_index())
orientations_d2
[23]:
dip azimuth Z geometry polarity formation X Y
0 18.25 90.76 650.00 POINT (2034.068 2228.337) 1.00 D2 2034.07 2228.34
[24]:
orientations_d3 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'D3'].sort_values(by='Z', ascending=True).reset_index())
orientations_d3
[24]:
dip azimuth Z geometry polarity formation X Y
0 17.12 90.05 650.00 POINT (2027.540 1148.092) 1.00 D3 2027.54 1148.09
1 17.07 90.49 750.00 POINT (1695.973 984.077) 1.00 D3 1695.97 984.08
[25]:
orientations_e = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'E'].sort_values(by='Z', ascending=True).reset_index())
orientations_e
[25]:
dip azimuth Z geometry polarity formation X Y
0 17.03 90.29 650.00 POINT (2358.563 1194.060) 1.00 E 2358.56 1194.06
1 18.62 90.97 750.00 POINT (2033.796 1095.868) 1.00 E 2033.80 1095.87
[26]:
orientations_e1 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'E1'].sort_values(by='Z', ascending=True).reset_index())
orientations_e1
[26]:
dip azimuth Z geometry polarity formation X Y
0 17.56 270.33 650.00 POINT (2862.034 1255.124) 1.00 E1 2862.03 1255.12
1 17.18 270.30 750.00 POINT (3188.841 1215.140) 1.00 E1 3188.84 1215.14
[27]:
orientations_e2 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'E2'].sort_values(by='Z', ascending=True).reset_index())
orientations_e2
[27]:
dip azimuth Z geometry polarity formation X Y
0 16.52 88.10 650.00 POINT (2354.483 2258.121) 1.00 E2 2354.48 2258.12
[28]:
orientations_e3 = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'E3'].sort_values(by='Z', ascending=True).reset_index())
orientations_e3
[28]:
dip azimuth Z geometry polarity formation X Y
0 16.77 271.06 650.00 POINT (2872.642 2298.377) 1.00 E3 2872.64 2298.38
[29]:
orientations_y = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'Y'].sort_values(by='Z', ascending=True).reset_index())
orientations_y
[29]:
dip azimuth Z geometry polarity formation X Y
0 5.08 23.65 950.00 POINT (3167.489 2716.440) 1.00 Y 3167.49 2716.44

Merging Orientations#

[30]:
import pandas as pd
orientations = pd.concat([orientations_b, orientations_b1, orientations_c, orientations_c1, orientations_c2, orientations_d, orientations_d1, orientations_d2, orientations_d3, orientations_e, orientations_e1, orientations_e2, orientations_e3, orientations_y]).reset_index()
orientations['formation'] = ['B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'E', 'E', 'Y']
orientations
[30]:
index dip azimuth Z geometry polarity formation X Y
0 0 0.00 0.00 500.00 POINT (1122.327 2045.418) 1.00 B 1122.33 2045.42
1 0 0.00 0.00 500.00 POINT (1123.143 973.537) 1.00 B 1123.14 973.54
2 0 18.07 269.32 450.00 POINT (536.440 1893.778) 1.00 C 536.44 1893.78
3 1 16.77 269.96 550.00 POINT (861.343 1916.762) 1.00 C 861.34 1916.76
4 0 18.26 90.30 550.00 POINT (1379.502 2078.602) 1.00 C 1379.50 2078.60
5 0 18.26 90.30 550.00 POINT (1379.502 2078.602) 1.00 C 1379.50 2078.60
6 0 17.00 270.73 650.00 POINT (211.673 1877.322) 1.00 D 211.67 1877.32
7 0 16.79 268.97 650.00 POINT (212.217 684.878) 1.00 D 212.22 684.88
8 0 18.25 90.76 650.00 POINT (2034.068 2228.337) 1.00 D 2034.07 2228.34
9 0 17.12 90.05 650.00 POINT (2027.540 1148.092) 1.00 D 2027.54 1148.09
10 1 17.07 90.49 750.00 POINT (1695.973 984.077) 1.00 D 1695.97 984.08
11 0 17.03 90.29 650.00 POINT (2358.563 1194.060) 1.00 E 2358.56 1194.06
12 1 18.62 90.97 750.00 POINT (2033.796 1095.868) 1.00 E 2033.80 1095.87
13 0 17.56 270.33 650.00 POINT (2862.034 1255.124) 1.00 E 2862.03 1255.12
14 1 17.18 270.30 750.00 POINT (3188.841 1215.140) 1.00 E 3188.84 1215.14
15 0 16.52 88.10 650.00 POINT (2354.483 2258.121) 1.00 E 2354.48 2258.12
16 0 16.77 271.06 650.00 POINT (2872.642 2298.377) 1.00 E 2872.64 2298.38
17 0 5.08 23.65 950.00 POINT (3167.489 2716.440) 1.00 Y 3167.49 2716.44

Plotting the Orientations#

[31]:
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, 4642)
ax.set_ylim(0, 3519)
[31]:
(0.0, 3519.0)
../../_images/getting_started_example_example06_48_1.png

GemPy Model Construction#

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

[32]:
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#

[33]:
geo_model = gp.create_model('Model6')
geo_model
[33]:
Model6  2022-04-05 08:26

Initiate Data#

[34]:
gp.init_data(geo_model, [0, 4642, 0, 3519, 0, 1500], [100, 100, 100],
             surface_points_df=interfaces_coords[interfaces_coords['Z'] != 0],
             orientations_df=orientations,
             default_values=True)
Active grids: ['regular']
[34]:
Model6  2022-04-05 08:26

Model Surfaces#

[35]:
geo_model.surfaces
[35]:
surface series order_surfaces color id
0 Y Default series 1 #015482 1
1 X Default series 2 #9f0052 2
2 E Default series 3 #ffbe00 3
3 D Default series 4 #728f02 4
4 C Default series 5 #443988 5
5 B Default series 6 #ff3f20 6

Mapping the Stack to Surfaces#

[36]:
gp.map_stack_to_surfaces(geo_model,
                         {
                          'Strata1': ('Y', 'X'),
                          'Strata2': ('E', 'D', 'C', 'B'),
                         },
                         remove_unused_series=True)
geo_model.add_surfaces('A')
[36]:
surface series order_surfaces color id
0 Y Strata1 1 #015482 1
1 X Strata1 2 #9f0052 2
2 E Strata2 1 #ffbe00 3
3 D Strata2 2 #728f02 4
4 C Strata2 3 #443988 5
5 B Strata2 4 #ff3f20 6
6 A Strata2 5 #5DA629 7

Showing the Number of Data Points#

[37]:
gg.utils.show_number_of_data_points(geo_model=geo_model)
[37]:
surface series order_surfaces color id No. of Interfaces No. of Orientations
0 Y Strata1 1 #015482 1 57 1
1 X Strata1 2 #9f0052 2 84 0
2 E Strata2 1 #ffbe00 3 84 6
3 D Strata2 2 #728f02 4 110 5
4 C Strata2 3 #443988 5 68 4
5 B Strata2 4 #ff3f20 6 51 2
6 A Strata2 5 #5DA629 7 0 0

Loading Digital Elevation Model#

[38]:
geo_model.set_topography(
    source='gdal', filepath=file_path + 'raster6.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']
[38]:
Grid Object. Values:
array([[  23.21      ,   17.595     ,    7.5       ],
       [  23.21      ,   17.595     ,   22.5       ],
       [  23.21      ,   17.595     ,   37.5       ],
       ...,
       [4636.99784483, 3494.00710227, 1253.95422363],
       [4636.99784483, 3504.00426136, 1257.55334473],
       [4636.99784483, 3514.00142045, 1261.13220215]])

Plotting Input Data#

[39]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
../../_images/getting_started_example_example06_64_0.png
[40]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
../../_images/getting_started_example_example06_65_0.png
[40]:
<gempy.plot.vista.GemPyToVista at 0x15aa7dcd2e0>

Setting the Interpolator#

[41]:
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:  0
Compilation Done!
Kriging values:
                    values
range             6015.11
$C_o$           861464.88
drift equations    [3, 3]
[41]:
<gempy.core.interpolator.InterpolatorModel at 0x15aa61133d0>

Computing Model#

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

Plotting Cross Sections#

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

Plotting 3D Model#

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