1 2 3 4 5 6 7 8 | import PVGeo import numpy as np import pandas as pd import pyvista print('NumPy Version: %s' % np.__version__) print('PVGeo Version: %s' % PVGeo.__version__) print('pyvista Version: %s' % pyvista.__version__) |
1 2 3 | NumPy Version: 1.18.5 PVGeo Version: 2.1.0 pyvista Version: 0.24.2 |
Welcome to PVGeo
Thanks for checking out this notebook! We hope this provides some insight on how you can get started using PVGeo in your Python (3) routines. Let’s get started!
At the top of this notebook, we import
A simple way to update PVGeo from your Jupyter Notebook:
1 | !pip install --upgrade PVGeo |
We have placed some data files in the
1. Introduction to PVGeo
What is PVGeo?
- Python package for 3D/4D geovisualization.
- Create compelling and integrated visualizations.
- Built upon VTK, a scalable and well-maintained visualization library.
- Extends geovisualization into ParaView, VTK.js, and Virtual Reality.
- Open-source and automatically deployed.

Abstract
PVGeo is an open-source Python package for geoscientific visualization and analysis, harnessing an already powerful software platform: the Visualization Toolkit (VTK) and its front-end application, ParaView. The VTK software platform is well-maintained, contains an expansive set of native functionality, and provides a robust foundation for scientific visualization, yet the development of tools compatible for geoscience data and models has been limited. As a software extension package to VTK and ParaView, PVGeo addresses the lack of geoscientific compatibility by creating a framework for geovisualization. This framework is a set of tools for visually integrating geoscience data and models directly within ParaView’s graphical user interface, simplifying the required routines to make compelling visualizations of geoscientific datasets. PVGeo aims to make the process of importing data into ParaView simple and fluid for users while providing a guide for contributions avoiding the typical, ambitious programming endeavor of building ParaView plugins. The PVGeo package is available for download on PyPI (pip install PVGeo), documented online, and open-source on GitHub for community-driven development.
PVGeo Resources
- Brief demo page
- Slcak community
- The code
- Use examples in ParaView
- Nitty gritty code docs
- Vimeo video examples
Take aways
- Join PVGeo on Slack
- The slack workspace is for anyone using ParaView for geovisualization
- Presentation at AGU in December 2018
- ParaView natively extends into VR (dynamically linked)
- VTK and ParaView are incredibly scalable
- PVGeo is Python based and open-source
Filtering Data with PVGeo
Table to Points
Let’s go ahead and load a simple file that has XYZ coordinates and a boolean array for fault presence. This point cloud makes some sort of regular grid, but we have forgotten the deatials of the cell spacings and local coordinate rotations.
We will read in this data with pandas and send it to the PVGeo filter
1 2 3 | import pandas as pd points = pd.read_csv('data/fault_points.csv') points[0:2] |
| X | Y | Z | Fault | |
|---|---|---|---|---|
| 0 | 326819.497 | 4407450.636 | 1287.5 | 0 |
| 1 | 326834.340 | 4407470.753 | 1287.5 | 0 |
1 2 3 | # Convert to vista.PolyData (assumes first this three columns are XYZ) vtkpoints = PVGeo.points_to_poly_data(points) vtkpoints |
| Header | Data Arrays | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| Name | Field | Type | N Comp | Min | Max |
|---|---|---|---|---|---|
| Fault | Points | float64 | 1 | 0.000e+00 | 1.000e+00 |
Note that we have a
To threshold the points, we call the
We can then plot the result by calling the
1 | vtkpoints.plot(clim=[0,1]) |

Points to Voxelized Volume
The above figure is pretty cools! But its a point cloud which means out filtering options are pretty limited. Fortunately, we know that the point cloud represents some sort of regularlized gridded volume of data and
Remember that these points are rotated and we do not know the cell sizes… this is okay! The
1 2 3 4 5 6 7 8 9 10 11 | # The full pipeline method print('Voxelizing... ', end='') voxelizer = PVGeo.filters.VoxelizePoints() #print(dir(voxelizer)) grid = voxelizer.apply(vtkpoints) print('done.') # Output the results print('Recovered Angle (deg.): %.3f' % voxelizer.get_recovered_angle()) print('Recovered Cell Sizes: (%.2f, %.2f, %.2f)' % voxelizer.get_spacing()) grid |
1 2 3 | Voxelizing... done. Recovered Angle (deg.): 53.550 Recovered Cell Sizes: (25.00, 25.00, 25.00) |
| Header | Data Arrays | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| Name | Field | Type | N Comp | Min | Max |
|---|---|---|---|---|---|
| Fault | Cells | float64 | 1 | 0.000e+00 | 1.000e+00 |
| Recovered Angle (Deg.) | Fields | float64 | 1 | 5.355e+01 | 5.355e+01 |
| Recovered Cell Sizes | Fields | float64 | 3 | 2.500e+01 | 2.500e+01 |
1 2 3 | # A simpler method to voxelize # grid = PVGeo.filters.VoxelizePoints().Apply(vtkpoints) # grid |
Now we have a volumetric dataset in the form of a
Slice Volumetric Data
Now lets use one of
1 2 | slices = grid.slice_orthogonal() slices |
| Information | Blocks | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| Index | Name | Type |
|---|---|---|
| 0 | YZ | PolyData |
| 1 | XZ | PolyData |
| 2 | XY | PolyData |
Integrated Visualization
Up to this point, we have filtered a single dataset and plotted the result by itself; this is usefult, but what if we have all kinds of data we want to throw into one rendering environment? Its pretty easy:
For a simple case, see below. Otherwise, move on to our next notebooks that run through bigger datasets and show how to combine data feature like a 3D model with topography surfaces, well trajectories, and more!
1 | clip = grid.clip(normal='x').clip(normal='-y').threshold(0.5) |
1 2 3 4 5 | p = pyvista.Plotter() p.add_mesh(slices) p.add_mesh(clip) p.show_grid() p.show() |

Reference
PVGeo-Examples