Example 12 - Three Point Problem#

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 2964 m wide (W-E extent) and 3725 m high (N-S extent). the vertical model extent varies between 0 m and 1000 m. This example represents a classic “three-point-problem” of a planar dipping layer (blue) above a basement (purple).

The map has been georeferenced with QGIS. The outcrops of the layers were digitized in QGIS. 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_example12.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example12_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/example12/'
gg.download_gemgis_data.download_tutorial_data(filename="example12_three_point_problem.zip", dirpath=file_path)
Downloading file 'example12_three_point_problem.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2Fexample12_three_point_problem.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\example\data\example12'.

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_example12.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example12_10_0.png
[6]:
topo = gpd.read_file(file_path + 'topo12.shp')
topo.head()
[6]:
id Z geometry
0 None 400 LINESTRING (166.181 5.047, 217.108 44.754, 269...
1 None 400 LINESTRING (3.471 901.028, 85.474 844.490, 153...
2 None 300 LINESTRING (1859.740 4.184, 1840.318 64.175, 1...
3 None 200 LINESTRING (2158.400 4.831, 2123.010 99.134, 2...
4 None 500 LINESTRING (1942.173 2049.057, 2007.344 2055.5...

Interpolating the contour lines#

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

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, 2966, 0, 3725], 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, 2966)
ax.set_ylim(0, 3725)
[8]:
(0.0, 3725.0)
../../_images/getting_started_example_example12_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 + 'raster12.tif', extent=[0,2966,0,3725], 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 + 'raster12.tif')

Interface Points of stratigraphic boundaries#

The interface points for this three point example will be digitized as points with the respective height value as given by the contour lines and the respective formation.

[10]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/interfaces_example12.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example12_21_0.png
[11]:
interfaces = gpd.read_file(file_path + 'interfaces12.shp')
interfaces.head()
[11]:
id formation Z geometry
0 None Coal 600 POINT (104.302 1770.385)
1 None Coal 400 POINT (1696.262 1775.038)
2 None Coal 200 POINT (1842.732 602.462)

Extracting Z coordinate from Digital Elevation Model#

[12]:
interfaces_coords = gg.vector.extract_xyz(gdf=interfaces, dem=None)
interfaces_coords
[12]:
formation Z geometry X Y
0 Coal 600.00 POINT (104.302 1770.385) 104.30 1770.39
1 Coal 400.00 POINT (1696.262 1775.038) 1696.26 1775.04
2 Coal 200.00 POINT (1842.732 602.462) 1842.73 602.46

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, 2966)
ax.set_ylim(0, 3725)
[13]:
(0.0, 3725.0)
../../_images/getting_started_example_example12_26_1.png

Orientations from Strike Lines#

For this three point example, an orientation is calculated using gg.vector.calculate_orientation_for_three_point_problem().

[14]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('../images/orientations_example12.png')
plt.figure(figsize=(10, 10))
imgplot = plt.imshow(img)
plt.axis('off')
plt.tight_layout()
../../_images/getting_started_example_example12_28_0.png
[15]:
orientations = gg.vector.calculate_orientation_for_three_point_problem(gdf=interfaces)
orientations
[15]:
Z formation azimuth dip polarity X Y geometry
0 400.0 Coal 140.84 11.29 1 1214.43 1382.63 POINT (1214.432 1382.628)

Setting the data type of the fields#

[16]:
orientations['Z'] = orientations['Z'].astype(float)
orientations['azimuth'] = orientations['azimuth'].astype(float)
orientations['dip'] = orientations['dip'].astype(float)
orientations['polarity'] = orientations['polarity'].astype(float)
orientations['X'] = orientations['X'].astype(float)
orientations['Y'] = orientations['Y'].astype(float)
orientations.info()
<class 'geopandas.geodataframe.GeoDataFrame'>
RangeIndex: 1 entries, 0 to 0
Data columns (total 8 columns):
 #   Column     Non-Null Count  Dtype
---  ------     --------------  -----
 0   Z          1 non-null      float64
 1   formation  1 non-null      object
 2   azimuth    1 non-null      float64
 3   dip        1 non-null      float64
 4   polarity   1 non-null      float64
 5   X          1 non-null      float64
 6   Y          1 non-null      float64
 7   geometry   1 non-null      geometry
dtypes: float64(6), geometry(1), object(1)
memory usage: 192.0+ bytes

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, 2966)
ax.set_ylim(0, 3725)
[17]:
(0.0, 3725.0)
../../_images/getting_started_example_example12_33_1.png

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('Model12')
geo_model
[19]:
Model12  2022-04-05 11:03

Initiate Data#

[20]:
gp.init_data(geo_model, [0, 2966, 0, 3725, 0, 1000], [100, 100, 100],
             surface_points_df=interfaces_coords[interfaces_coords['Z'] != 0],
             orientations_df=orientations,
             default_values=True)
Active grids: ['regular']
[20]:
Model12  2022-04-05 11:03

Model Surfaces#

[21]:
geo_model.surfaces
[21]:
surface series order_surfaces color id
0 Coal Default series 1 #015482 1

Mapping the Stack to Surfaces#

[22]:
gp.map_stack_to_surfaces(geo_model,
                         {
                          'Strata1': ('Coal'),
                         },
                         remove_unused_series=True)
geo_model.add_surfaces('Basement')
[22]:
surface series order_surfaces color id
0 Coal Strata1 1 #015482 1
1 Basement Strata1 2 #9f0052 2

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 Coal Strata1 1 #015482 1 3 1
1 Basement Strata1 2 #9f0052 2 0 0

Loading Digital Elevation Model#

[24]:
geo_model.set_topography(
    source='gdal', filepath=file_path + 'raster12.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([[  14.83      ,   18.625     ,    5.        ],
       [  14.83      ,   18.625     ,   15.        ],
       [  14.83      ,   18.625     ,   25.        ],
       ...,
       [2958.51010101, 3687.44959677,  556.33007812],
       [2958.51010101, 3702.46975806,  558.58599854],
       [2958.51010101, 3717.48991935,  560.82910156]])

Plotting Input Data#

[25]:
gp.plot_2d(geo_model, direction='z', show_lith=False, show_boundaries=False)
plt.grid()
../../_images/getting_started_example_example12_49_0.png
[26]:
gp.plot_3d(geo_model, image=False, plotter_type='basic', notebook=True)
../../_images/getting_started_example_example12_50_0.png
[26]:
<gempy.plot.vista.GemPyToVista at 0x1e22fef8130>

Setting the Interpolator#

[27]:
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             4865.47
$C_o$           563637.64
drift equations       [3]
[27]:
<gempy.core.interpolator.InterpolatorModel at 0x1e228fd5e20>

Computing Model#

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

Plotting Cross Sections#

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

Plotting 3D Model#

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