Note
Click here to download the full example code
Surface DecimationΒΆ
Decimate some of the surfaces to make them more manageable with web renderings in VTK.js
import gdc19
import pandas as pd
import numpy as np
import pyvista
import omfvista
import PVGeo
import omf
surfaces = omfvista.load_project(gdc19.get_project_path('surfaces.omf'))
topo = surfaces['land_surface']
Decimate Topography Surface
dec = topo.extract_geometry().decimate(0.99, inplace=False)
dec.plot(notebook=True, show_edges=True, color=True)
Out:
<PIL.Image.Image image mode=RGB size=2048x1536 at 0x7FF7A9B30AC8>
Re-do the texture mapping
reader = omf.OMFReader(gdc19.get_project_path('surfaces.omf'))
project = reader.get_project()
# Assumes 'land_surface' is at index 0
surf = project.elements[0]
tex = surf.textures[0]
print(tex.name)
og = tex.origin
pu = tex.axis_u
pv = tex.axis_v
dec.texture_map_to_plane(origin=og, point_u=og+pu, point_v=og+pv,
inplace=True, name='geo_aer')
dec.textures['geo_aer'] = pyvista.read_texture(gdc19.get_web_path('geology-aerial-compressed.jpg'))
dec.plot(texture=True)
dec.save(gdc19.get_web_path('topo.vtk'))
Out:
geo_aer
Decimate Granite Surface
gran = surfaces['top_granitoid']
print(gran)
Out:
UnstructuredGrid (0x7ff7a9b3a588)
N Cells: 205980
N Points: 103455
X Bounds: 3.300e+05, 3.442e+05
Y Bounds: 4.253e+06, 4.271e+06
Z Bounds: -2.112e+03, 2.723e+03
N Arrays: 0
dec = gran.extract_geometry().decimate(0.99, inplace=False)
dec.plot(notebook=True, show_edges=True)
dec.save(gdc19.get_web_path('granite.vtk'))
Out:
<PIL.Image.Image image mode=RGB size=2048x1536 at 0x7FF7A9B30FD0>
Total running time of the script: ( 0 minutes 25.947 seconds)