Example 4 - Unconformably Dipping Layers
Contents
Example 4 - Unconformably Dipping 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 2963 m wide (W-E extent) and 3715 m high (N-S extent). The vertical model extent varies between 0 m and 1000 m. The model represents several planar stratigraphic units (yellow to light red) dipping towards the west above an unspecified basement (green). The blue and purple unit overlay the remaining strata unconformably and dip to the north.
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_example04.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
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/example04/'
gg.download_gemgis_data.download_tutorial_data(filename="example04_unconformably_dipping_layers.zip", dirpath=file_path)
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_example04.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[6]:
topo = gpd.read_file(file_path + 'topo4.shp')
topo.head()
[6]:
id | Z | geometry | |
---|---|---|---|
0 | None | 600 | LINESTRING (-1.172 334.506, 98.350 346.728, 21... |
1 | None | 500 | LINESTRING (1088.333 6.258, 1182.617 58.638, 1... |
2 | None | 200 | LINESTRING (2947.824 83.082, 2785.446 201.810,... |
3 | None | 300 | LINESTRING (2694.654 8.004, 2549.736 86.574, 2... |
4 | None | 400 | LINESTRING (2202.282 2.766, 2032.919 95.304, 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, 2963, 0, 3715], 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, 2963)
ax.set_ylim(0, 3715)
[8]:
(0.0, 3715.0)
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.
Opening Raster#
The previously computed and saved raster can now be opened using rasterio.
[9]:
topo_raster = rasterio.open(file_path + 'raster4.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_example04.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[11]:
interfaces = gpd.read_file(file_path + 'interfaces4.shp')
interfaces.head()
[11]:
id | formation | geometry | |
---|---|---|---|
0 | None | M | LINESTRING (2320.137 7.131, 2206.647 164.271, ... |
1 | None | N | LINESTRING (1688.084 5.385, 1677.608 50.781, 1... |
2 | None | O | LINESTRING (1286.504 1.893, 1314.440 45.543, 1... |
3 | None | P | LINESTRING (760.957 0.147, 804.607 49.035, 830... |
4 | None | Y | LINESTRING (8.431 1206.634, 149.857 1281.712, ... |
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
[12]:
formation | geometry | X | Y | Z | |
---|---|---|---|---|---|
193 | Z | POINT (1581.578 2671.529) | 1581.58 | 2671.53 | 663.80 |
196 | Z | POINT (1611.260 2462.009) | 1611.26 | 2462.01 | 680.92 |
187 | Z | POINT (305.251 1952.176) | 305.25 | 1952.18 | 742.32 |
188 | Z | POINT (200.491 1885.828) | 200.49 | 1885.83 | 748.24 |
189 | Z | POINT (81.763 1819.480) | 81.76 | 1819.48 | 752.76 |
... | ... | ... | ... | ... | ... |
19 | M | POINT (2760.129 1096.636) | 2760.13 | 1096.64 | 378.75 |
20 | M | POINT (2889.333 1084.414) | 2889.33 | 1084.41 | 414.59 |
21 | M | POINT (2950.443 1075.684) | 2950.44 | 1075.68 | 430.87 |
1 | M | POINT (2206.647 164.271) | 2206.65 | 164.27 | 343.14 |
0 | M | POINT (2320.137 7.131) | 2320.14 | 7.13 | 375.57 |
271 rows × 5 columns
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, 2963)
ax.set_ylim(0, 3715)
[13]:
(0.0, 3715.0)
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_example04.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[15]:
strikes = gpd.read_file(file_path + 'strikes4.shp')
strikes
[15]:
id | formation | Z | geometry | |
---|---|---|---|---|
0 | 3 | Z | 700 | LINESTRING (532.231 2126.776, 2622.195 2125.030) |
1 | 2 | Z | 600 | LINESTRING (729.529 2846.129, 2660.607 2863.589) |
2 | 1 | M | 300 | LINESTRING (2307.915 1121.080, 2065.220 359.823) |
3 | 2 | M | 400 | LINESTRING (2836.953 1094.890, 2479.023 -125.566) |
4 | 2 | N | 400 | LINESTRING (2019.824 1695.514, 1534.436 356.331) |
5 | 1 | N | 300 | LINESTRING (1466.342 1660.594, 902.383 96.177) |
6 | 2 | P | 500 | LINESTRING (1197.458 1655.356, 738.259 386.013) |
7 | 1 | P | 400 | LINESTRING (516.517 1208.380, 186.523 361.569) |
8 | 3 | N | 500 | LINESTRING (2490.372 1610.833, 1942.127 4.512) |
9 | 1 | Z | 500 | LINESTRING (616.039 3606.513, 2409.183 3614.370) |
Calculate Orientations for each formation#
[16]:
orientations_m = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'M'].sort_values(by='id', ascending=True).reset_index())
orientations_m
[16]:
dip | azimuth | Z | geometry | polarity | formation | X | Y | |
---|---|---|---|---|---|---|---|---|
0 | 10.99 | 286.72 | 350.00 | POINT (2422.278 612.557) | 1.00 | M | 2422.28 | 612.56 |
[17]:
orientations_n = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'N'].sort_values(by='Z', ascending=True).reset_index())
orientations_n
[17]:
dip | azimuth | Z | geometry | polarity | formation | X | Y | |
---|---|---|---|---|---|---|---|---|
0 | 11.17 | 289.87 | 350.00 | POINT (1480.746 952.154) | 1.00 | N | 1480.75 | 952.15 |
1 | 11.95 | 289.29 | 450.00 | POINT (1996.690 916.797) | 1.00 | N | 1996.69 | 916.80 |
[18]:
orientations_p = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'P'].sort_values(by='Z', ascending=True).reset_index())
orientations_p
[18]:
dip | azimuth | Z | geometry | polarity | formation | X | Y | |
---|---|---|---|---|---|---|---|---|
0 | 11.57 | 290.32 | 450.00 | POINT (659.689 902.829) | 1.00 | P | 659.69 | 902.83 |
[19]:
orientations_y = gg.vector.calculate_orientations_from_strike_lines(gdf=strikes[strikes['formation'] == 'Z'].sort_values(by='Z', ascending=True).reset_index())
orientations_y
[19]:
dip | azimuth | Z | geometry | polarity | formation | X | Y | |
---|---|---|---|---|---|---|---|---|
0 | 7.56 | 359.61 | 550.00 | POINT (1603.840 3232.650) | 1.00 | Z | 1603.84 | 3232.65 |
1 | 7.91 | 359.79 | 650.00 | POINT (1636.141 2490.381) | 1.00 | Z | 1636.14 | 2490.38 |
Merging Orientations#
[20]:
import pandas as pd
orientations = pd.concat([orientations_m, orientations_n, orientations_p, orientations_y]).reset_index()
orientations
[20]:
index | dip | azimuth | Z | geometry | polarity | formation | X | Y | |
---|---|---|---|---|---|---|---|---|---|
0 | 0 | 10.99 | 286.72 | 350.00 | POINT (2422.278 612.557) | 1.00 | M | 2422.28 | 612.56 |
1 | 0 | 11.17 | 289.87 | 350.00 | POINT (1480.746 952.154) | 1.00 | N | 1480.75 | 952.15 |
2 | 1 | 11.95 | 289.29 | 450.00 | POINT (1996.690 916.797) | 1.00 | N | 1996.69 | 916.80 |
3 | 0 | 11.57 | 290.32 | 450.00 | POINT (659.689 902.829) | 1.00 | P | 659.69 | 902.83 |
4 | 0 | 7.56 | 359.61 | 550.00 | POINT (1603.840 3232.650) | 1.00 | Z | 1603.84 | 3232.65 |
5 | 1 | 7.91 | 359.79 | 650.00 | POINT (1636.141 2490.381) | 1.00 | Z | 1636.14 | 2490.38 |
Plotting the Orientations#
[21]:
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, 2963)
ax.set_ylim(0, 3715)
[21]:
(0.0, 3715.0)
GemPy Model Construction#
The structural geological model will be constructed using the GemPy
package.
[22]:
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#
[23]:
geo_model = gp.create_model('Model4')
geo_model
[23]:
Model4 2022-04-04 18:59
Initiate Data#
[24]:
gp.init_data(geo_model, [0, 2963, 0, 3715, 0, 1000], [100, 100, 100],
surface_points_df=interfaces_coords[interfaces_coords['Z'] != 0],
orientations_df=orientations,
default_values=True)
Active grids: ['regular']
[24]:
Model4 2022-04-04 18:59
Model Surfaces#
[25]:
geo_model.surfaces
[25]:
surface | series | order_surfaces | color | id | |
---|---|---|---|---|---|
0 | Z | Default series | 1 | #015482 | 1 |
1 | Y | Default series | 2 | #9f0052 | 2 |
2 | P | Default series | 3 | #ffbe00 | 3 |
3 | O | Default series | 4 | #728f02 | 4 |
4 | N | Default series | 5 | #443988 | 5 |
5 | M | Default series | 6 | #ff3f20 | 6 |
Mapping the Stack to Surfaces#
[26]:
gp.map_stack_to_surfaces(geo_model,
{
'Strata1': ('Z', 'Y'),
'Strata2': ('P', 'O', 'N', 'M'),
},
remove_unused_series=True)
geo_model.add_surfaces('Basement')
[26]:
surface | series | order_surfaces | color | id | |
---|---|---|---|---|---|
0 | Z | Strata1 | 1 | #015482 | 1 |
1 | Y | Strata1 | 2 | #9f0052 | 2 |
2 | P | Strata2 | 1 | #ffbe00 | 3 |
3 | O | Strata2 | 2 | #728f02 | 4 |
4 | N | Strata2 | 3 | #443988 | 5 |
5 | M | Strata2 | 4 | #ff3f20 | 6 |
6 | Basement | Strata2 | 5 | #5DA629 | 7 |
Showing the Number of Data Points#
[27]:
gg.utils.show_number_of_data_points(geo_model=geo_model)
[27]:
surface | series | order_surfaces | color | id | No. of Interfaces | No. of Orientations | |
---|---|---|---|---|---|---|---|
0 | Z | Strata1 | 1 | #015482 | 1 | 62 | 2 |
1 | Y | Strata1 | 2 | #9f0052 | 2 | 55 | 0 |
2 | P | Strata2 | 1 | #ffbe00 | 3 | 33 | 1 |
3 | O | Strata2 | 2 | #728f02 | 4 | 50 | 0 |
4 | N | Strata2 | 3 | #443988 | 5 | 49 | 2 |
5 | M | Strata2 | 4 | #ff3f20 | 6 | 22 | 1 |
6 | Basement | Strata2 | 5 | #5DA629 | 7 | 0 | 0 |
Loading Digital Elevation Model#
[28]:
geo_model.set_topography(source='gdal', filepath=file_path + 'raster4.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']
[28]:
Grid Object. Values:
array([[ 14.815 , 18.575 , 5. ],
[ 14.815 , 18.575 , 15. ],
[ 14.815 , 18.575 , 25. ],
...,
[2958.01178451, 3690.03360215, 446.43917847],
[2958.01178451, 3700.02016129, 445.69622803],
[2958.01178451, 3710.00672043, 444.99276733]])
Plotting Input Data#
[29]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
[30]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
[30]:
<gempy.plot.vista.GemPyToVista at 0x1f8883ae880>
Setting the Interpolator#
[31]:
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 4855.99
$C_o$ 561442.71
drift equations [3, 3]
[31]:
<gempy.core.interpolator.InterpolatorModel at 0x1f88515ab50>
Computing Model#
[32]:
sol = gp.compute_model(geo_model, compute_mesh=True)
Plotting Cross Sections#
[33]:
gp.plot_2d(geo_model, direction=['x', 'x', 'y', 'y'], cell_number=[25, 75, 25, 75], show_topography=True, show_data=False)
[33]:
<gempy.plot.visualization_2d.Plot2D at 0x1f889906940>
Plotting 3D Model#
[34]:
gpv = gp.plot_3d(geo_model, image=False, show_topography=True,
plotter_type='basic', notebook=True, show_lith=True)
[ ]: