Note
Go to the end to download the full example code.
Meshing a shapefile#
Section author: Julian Heinze (Helmholtz Centre for Environmental Research GmbH - UFZ)
In this example we present how to create a unstructured grid in vtk format (*.vtu) from a shapefile.
Necessary imports
import ogstools.meshlib as ml
from ogstools.examples import test_shapefile
A shapefile can be directly read with meshlib to create a mesh.
mesh = ml.Mesh.read(test_shapefile)
mesh.plot(show_edges=True)
/builds/ogs/tools/ogstools/.venv-devcontainer/lib/python3.10/site-packages/pandamesh/common.py:283: RuntimeWarning: invalid value encountered in sqrt
area = np.sqrt(s * (s - a) * (s - b) * (s - c))
Total running time of the script: (0 minutes 6.251 seconds)