Example 1 - Planar Dipping Layers
Contents
Example 1 - Planar 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 972 m wide (W-E extent) and 1069 m high (N-S extent). The vertical model extents varies between 300 m and 800 m. The model represents two planar stratigraphic units (blue and red) dipping towards the south above an unspecified basement (yellow). The map has been georeferenced with QGIS. The stratigraphic boundaries were digitized in QGIS.
Strikes lines were digitized in QGIS as well and were used to calculate orientations for the GemPy
model. These will be loaded into the model directly. The contour lines were also digitized and will be interpolated with GemGIS
to create a topography for the model.
Map Source: Unknown
[1]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/cover.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 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/example01/'
gg.download_gemgis_data.download_tutorial_data(filename="example01_planar_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]:
img = mpimg.imread('../images/dem_example1.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[6]:
topo = gpd.read_file(file_path + 'topo1.shp')
topo.head()
[6]:
id | Z | geometry | |
---|---|---|---|
0 | None | 400 | LINESTRING (0.741 475.441, 35.629 429.247, 77.... |
1 | None | 300 | LINESTRING (645.965 0.525, 685.141 61.866, 724... |
2 | None | 400 | LINESTRING (490.292 0.525, 505.756 40.732, 519... |
3 | None | 600 | LINESTRING (911.433 1068.585, 908.856 1026.831... |
4 | None | 700 | LINESTRING (228.432 1068.585, 239.772 1017.037... |
Interpolating the contour lines#
[7]:
topo_raster = gg.vector.interpolate_raster(gdf=topo, value='Z', method='rbf', res=5)
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, 972, 0, 1069], 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, 972)
ax.set_ylim(0, 1069)
[8]:
(0.0, 1069.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 + 'raster1.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]:
img = mpimg.imread('../images/interfaces_example1.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[11]:
interfaces = gpd.read_file(file_path + 'interfaces1_lines.shp')
interfaces.head()
[11]:
id | formation | geometry | |
---|---|---|---|
0 | None | Sand1 | LINESTRING (0.256 264.862, 10.593 276.734, 17.... |
1 | None | Ton | LINESTRING (0.188 495.787, 8.841 504.142, 41.0... |
2 | None | Ton | LINESTRING (970.677 833.053, 959.372 800.023, ... |
Extracting Z coordinate from Digital Elevation Model#
[12]:
interfaces_coords = gg.vector.extract_xyz(gdf=interfaces, dem=topo_raster)
interfaces_coords
[12]:
formation | geometry | X | Y | Z | |
---|---|---|---|---|---|
0 | Sand1 | POINT (0.256 264.862) | 0.26 | 264.86 | 353.97 |
1 | Sand1 | POINT (10.593 276.734) | 10.59 | 276.73 | 359.04 |
2 | Sand1 | POINT (17.135 289.090) | 17.13 | 289.09 | 364.28 |
3 | Sand1 | POINT (19.150 293.313) | 19.15 | 293.31 | 364.99 |
4 | Sand1 | POINT (27.795 310.572) | 27.80 | 310.57 | 372.81 |
... | ... | ... | ... | ... | ... |
126 | Ton | POINT (636.023 859.788) | 636.02 | 859.79 | 618.32 |
127 | Ton | POINT (608.851 912.396) | 608.85 | 912.40 | 647.91 |
128 | Ton | POINT (560.110 990.617) | 560.11 | 990.62 | 697.06 |
129 | Ton | POINT (526.375 1045.388) | 526.38 | 1045.39 | 724.56 |
130 | Ton | POINT (512.240 1067.951) | 512.24 | 1067.95 | 734.76 |
131 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, 972)
ax.set_ylim(0, 1069)
[13]:
(0.0, 1069.0)
[14]:
fig, ax = plt.subplots(1, figsize=(10, 10))
#interfaces.plot(ax=ax, column='formation', legend=True, aspect='equal')
interfaces_coords.plot(ax=ax, column='Z', legend=True, aspect='equal', cmap='gist_earth')
plt.grid()
ax.set_xlabel('X [m]')
ax.set_ylabel('Y [m]')
# ax.set_xlim(0, 972)
# ax.set_ylim(0, 1069)
[14]:
Text(53.5, 0.5, 'Y [m]')
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.
For this example, the orientations were calculated beforehand and will just be loaded into GemPy
.
[15]:
img = mpimg.imread('../images/orientations_example1.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
[16]:
orientations = gpd.read_file(file_path + 'orientations1.shp')
orientations = gg.vector.extract_xyz(gdf=orientations, dem=topo_raster)
orientations['polarity'] = 1
orientations
[16]:
formation | dip | azimuth | geometry | X | Y | Z | polarity | |
---|---|---|---|---|---|---|---|---|
0 | Ton | 30.50 | 180.00 | POINT (96.471 451.564) | 96.47 | 451.56 | 440.59 | 1 |
1 | Ton | 30.50 | 180.00 | POINT (172.761 661.877) | 172.76 | 661.88 | 556.38 | 1 |
2 | Ton | 30.50 | 180.00 | POINT (383.074 957.758) | 383.07 | 957.76 | 729.02 | 1 |
3 | Ton | 30.50 | 180.00 | POINT (592.356 722.702) | 592.36 | 722.70 | 601.55 | 1 |
4 | Ton | 30.50 | 180.00 | POINT (766.586 348.469) | 766.59 | 348.47 | 378.63 | 1 |
5 | Ton | 30.50 | 180.00 | POINT (843.907 167.023) | 843.91 | 167.02 | 282.61 | 1 |
6 | Ton | 30.50 | 180.00 | POINT (941.846 428.883) | 941.85 | 428.88 | 423.45 | 1 |
7 | Ton | 30.50 | 180.00 | POINT (22.142 299.553) | 22.14 | 299.55 | 368.05 | 1 |
Plotting the Orientations#
[17]:
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, 972)
ax.set_ylim(0, 1069)
[17]:
(0.0, 1069.0)
GemPy Model Construction#
The structural geological model will be constructed using the GemPy
package.
[18]:
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#
[19]:
geo_model = gp.create_model('Model1')
geo_model
[19]:
Model1 2022-04-03 10:21
Initiate Data#
[20]:
gp.init_data(geo_model, [0, 972, 0, 1069, 300, 800], [100, 100, 100],
surface_points_df=interfaces_coords,
orientations_df=orientations,
default_values=True)
Active grids: ['regular']
[20]:
Model1 2022-04-03 10:21
Model Surfaces#
[21]:
geo_model.surfaces
[21]:
surface | series | order_surfaces | color | id | |
---|---|---|---|---|---|
0 | Sand1 | Default series | 1 | #015482 | 1 |
1 | Ton | Default series | 2 | #9f0052 | 2 |
Mapping the Stack to Surfaces#
[22]:
gp.map_stack_to_surfaces(geo_model,
{'Strata': ('Sand1', 'Ton')},
remove_unused_series=True)
geo_model.add_surfaces('Basement')
[22]:
surface | series | order_surfaces | color | id | |
---|---|---|---|---|---|
0 | Sand1 | Strata | 1 | #015482 | 1 |
1 | Ton | Strata | 2 | #9f0052 | 2 |
2 | Basement | Strata | 3 | #ffbe00 | 3 |
Showing the Number of Data Points#
[23]:
gg.utils.show_number_of_data_points(geo_model=geo_model)
[23]:
surface | series | order_surfaces | color | id | No. of Interfaces | No. of Orientations | |
---|---|---|---|---|---|---|---|
0 | Sand1 | Strata | 1 | #015482 | 1 | 95 | 0 |
1 | Ton | Strata | 2 | #9f0052 | 2 | 36 | 8 |
2 | Basement | Strata | 3 | #ffbe00 | 3 | 0 | 0 |
Loading Digital Elevation Model#
[24]:
geo_model.set_topography(source='gdal', filepath=file_path + 'raster1.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']
[24]:
Grid Object. Values:
array([[ 4.86 , 5.345 , 302.5 ],
[ 4.86 , 5.345 , 307.5 ],
[ 4.86 , 5.345 , 312.5 ],
...,
[ 970.056 , 1059.28181818, 622.0892334 ],
[ 970.056 , 1063.16909091, 622.06713867],
[ 970.056 , 1067.05636364, 622.05786133]])
Defining Custom Section#
[25]:
custom_section = gpd.read_file(file_path + 'customsections1.shp')
custom_section_dict = gg.utils.to_section_dict(custom_section, section_column='section')
geo_model.set_section_grid(custom_section_dict)
Active grids: ['regular' 'topography' 'sections']
[25]:
start | stop | resolution | dist | |
---|---|---|---|---|
Section1 | [1.372395262185787, 383.9794474025771] | [970.9954955186289, 383.8831909730347] | [100, 80] | 969.62 |
[26]:
gp.plot.plot_section_traces(geo_model)
[26]:
<gempy.plot.visualization_2d.Plot2D at 0x1bbcdf9d850>
Plotting Input Data#
[27]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
[28]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
[28]:
<gempy.plot.vista.GemPyToVista at 0x1bbd8884d90>
Setting the Interpolator#
[29]:
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 1528.9
$C_o$ 55655.83
drift equations [3]
[29]:
<gempy.core.interpolator.InterpolatorModel at 0x1bbd7d8b7f0>
Computing Model#
[30]:
sol = gp.compute_model(geo_model, compute_mesh=True)
Plotting Cross Sections#
[31]:
gp.plot_2d(geo_model, section_names=['Section1'], show_topography=True, show_data=False)
[31]:
<gempy.plot.visualization_2d.Plot2D at 0x1bbdda5b340>
[32]:
gp.plot_2d(geo_model, direction=['x', 'x', 'y', 'y'], cell_number=[25, 75, 25, 75], show_topography=True, show_data=False)
[32]:
<gempy.plot.visualization_2d.Plot2D at 0x1bbefba4970>
[33]:
gpv = gp.plot_3d(geo_model,
image=False,
show_topography=True,
plotter_type='basic',
notebook=True,
show_lith=True,
show_boundaries=True)
[ ]: