1. 首先安装python gempy 包
pip install gempy
python 版本 3.10 这个很重要,版本不同可能会报错
2. gdal 可能会报错, 一下地址根据python版本下载,然后移入到python解释器环境中, Script文件中,然后cmd ,pip install 文件名安装即可
Releases · cgohlke/geospatial-wheels · GitHub
3. 代码如下
import gempy as gp
import gemgis as gg
import pandas as pd
import matplotlib.pyplot as plt
import pyvista as pv
pd.options.display.precision = 2
import subprocess
data_path = './file'
geo_data = gp.create_data('horizontal', extent=[0, 1000, 0, 1000, -100, 200], resolution=[50, 50, 50],
path_o=data_path + "/fooil.csv",
path_i=data_path + "/inoil.csv")
gp.map_stack_to_surfaces(geo_data, {
"Strat_Series": ('Q4', 'K1Z', 'J2a', 'J2z', 'J1-2y', 'T3y', 'T2e', 'T1h', 'T1l', 'P2sh', 'P2s', 'P1x3'
, 'P1x2', 'P1x1A', 'P1x1B'), "Basement_Series": ('basement')})
# Set interpolator and compute model
interp_data = gp.set_interpolator(geo_data, compile_theano=True,
theano_optimizer='fast_compile')
gp.compute_model(geo_data)
gp.plot.plot_3d(geo_data,
plotter_type='basic', off_screen=False,
show_topography=True,
show_scalar=False,
show_lith=True,
kwargs_plot_structured_grid={'opacity': .5})
出现弹框, 模型会显示,我这块用的是pycharm开发工具
4. 导出功能,这里需要用到 gemgis,以及pyvista,正常安装即可
pip install gemgis
5. 代码
dict_sand1 = gg.visualization.create_depth_maps_from_gempy(geo_model=geo_data,
surfaces=['Q4', 'K1Z', 'J2a','J2z', 'J1-2y', 'T3y', 'T2e', 'T1h', 'T1l', 'P2sh', 'P2s', 'P1x3'
, 'P1x2', 'P1x1A', 'P1x1B'])
p = pv.Plotter(notebook=True)
p.add_mesh(dict_sand1['Q4'][0], color='#fd503e')
p.add_mesh(dict_sand1['K1Z'][0], color='red')
p.add_mesh(dict_sand1['J2a'][0], color='#39b362')
p.add_mesh(dict_sand1['J2z'][0], color='#5239b3')
p.add_mesh(dict_sand1['J1-2y'][0], color='#39b384')
p.add_mesh(dict_sand1['T3y'][0], color='#83b339')
p.add_mesh(dict_sand1['T2e'][0], color='#b38739')
p.add_mesh(dict_sand1['T1h'][0], color='#b34039')
p.add_mesh(dict_sand1['T1l'][0], color='#83b339')
p.add_mesh(dict_sand1['P2sh'][0], color='#b38739')
p.add_mesh(dict_sand1['P2s'][0], color='#b34039')
p.add_mesh(dict_sand1['P1x3'][0], color='#83b339')
p.add_mesh(dict_sand1['P1x2'][0], color='#b38739')
p.add_mesh(dict_sand1['P1x1A'][0], color='#b34039')
p.add_mesh(dict_sand1['P1x1B'][0], color='#b34039')
p.set_background('white')
p.show_grid(color='black')
# p.show()
p.export_gltf('test.gltf')