top of page

PyVista: Python’s Powerful 3D Visualization Engine

  • Writer: Anvita Shrivastava
    Anvita Shrivastava
  • Jul 23
  • 4 min read

Updated: 5 days ago

In the realm of scientific computing, 3D visualization serves a vital role when it comes to comprehending difficult datasets. Regardless of whether it's a case of terrain modeling, analysis of CFD, examination of medical images, or visualization of results of FEA, a reliable visualization tool has to be utilized.


PyVista stands out among the most helpful libraries in Python when it comes to 3D visualization. Built on the back of the Visualization Toolkit (VTK), PyVista allows any complicated process of visualization to be simplified into a smooth and accessible API.


PyVista
PyVista

What is PyVista?


PyVista is an open-source library in Python allowing for the easy creation and visualization of 3D models, datasets, and meshes using the Visualization Toolkit (VTK).


With PyVista, users can save time on writing complex VTK scripts.


Some of the features offered by PyVista include:


  • 3D mesh visualization

  • Surface rendering

  • Point cloud visualization

  • Isosurface creation

  • Volume rendering

  • Contouring

  • Interactive plotting

  • Visualization for scientific simulations

  • GIS terrain rendering


Since PyVista uses VTK in the background, it comprises technological sophistication, coupled with the functionality of VTK.


Why is PyVista Popular?


PyVista is popular because it is designed especially for scientific visualization.


Some of the causes of its wide popularity are:


  • Easy syntax

  • Very fast rendering

  • Interactive 3D windows

  • Good documentation

  • Compatibility with many platforms

  • Support for VTK data

  • Close cooperation with NumPy

  • Visualization with the Jupyter notebook

  • Efficient handling of huge datasets.


Key Features of PyVista


  1. Interactive 3D Rendering


With PyVista, users can manipulate their models by rotating, zooming in and out, and scrutinizing them in much detail.


  • Possible uses are:

  • Geologic modeling

  • Architectural modeling

  • CAD visualization

  • Terrain modeling

  • Engineering simulations


  1. Mesh Processing


PyVista offers users several different types of meshes:

  • Polygonal meshes

  • Structural grids

  • Unstructured grids

  • Surface meshes

  • Tetrahedral meshes

  • Hexagonal meshes


Filters provided with PyVista allow its users to apply different kinds of manipulations with meshes.


  1. Volume Rendering


PyVista is particularly successful in visualizing volumetric datasets, such as:

  • CT scans

  • MRI data

  • Weather modeling

  • Subsurface geology

  • Density fields


  1. Visualizing Point Cloud


The processing of expansive LiDAR databases is performed effectively.


Some common applications are:

  • Drone LiDAR

  • Airborne LiDAR

  • Mapping of forests

  • Inspection of utilities

  • Urban mapping


  1. Generating Contours


Contour surfaces are produced from scalar fields by PyVista.


For instance:

  • Elevation contours

  • Temperature surfaces

  • Pressure fields

  • Water levels


  1. Animation Features


Users can make:

  • Rotating models

  • Time series animation

  • Dynamic scientific illustrations

  • Camera animations


  1. Ready-made Filters


PyVista has a huge variety of filters:

  • Clip

  • Slice

  • Threshold

  • Warp

  • Smooth

  • Decimate

  • Streamlines

  • Glyphs

  • Connectivity


  1. Various Formats


PyVista can read and write files in:

  • VTK format

  • STL format

  • OBJ format

  • PLY format

  • Exodus format

  • VTU format

  • VTP format

  • OpenFOAM format

  • CGNS format



What Is PyVista? Exploring Python's Powerful 3D Visualization Engine



Installing PyVista


Installation is straightforward using pip:

pip install pyvista

Or install with Conda:

conda install -c conda-forge pyvista

To verify the installation:

import pyvista as pv

print(pv.__version__)

Creating Your First 3D Visualization


One of PyVista's greatest strengths is how little code is needed.

import pyvista as pv

sphere = pv.Sphere()

sphere.plot()

This simple script opens an interactive 3D rendering window containing a sphere.


Creating a Terrain Surface


Terrain visualization is especially useful for GIS professionals.

import pyvista as pv

terrain = pv.examples.load_random_hills()

terrain.plot(cmap="terrain")

This creates an interactive terrain model.


Working with Point Clouds


PyVista can visualize millions of points.

import pyvista as pv
import numpy as np

points = np.random.rand(1000, 3)

cloud = pv.PolyData(points)

cloud.plot(
    render_points_as_spheres=True,
    point_size=8
)

Adding Colors


Scalar values can control coloring.

mesh = pv.Sphere()

mesh["Elevation"] = mesh.points[:,2]

mesh.plot(
    scalars="Elevation",
    cmap="viridis"
)

Creating Contours


mesh = pv.examples.load_random_hills()

contours = mesh.contour()

contours.plot()

Volume Rendering Example


Medical and geological datasets often require volume rendering.

import pyvista as pv

dataset = pv.examples.download_knee_full()

plotter = pv.Plotter()

plotter.add_volume(dataset)

plotter.show()

The Practical Uses of PyVista in GIS


PyVista is making a big difference when it comes to geospatial tasks.


Some regular GIS uses involve:



The ability to render elevation models using real-time lighting.



The ability to visualize buildings, vegetation, and terrain.



The ability to show off LAS and LAZ files after they’ve been processed.


Watershed Visualization


The ability to visualize hydrological models created from DEM sources.


Terrain Analysis


Ability to produce:

  • Hillshading

  • Slope

  • Aspect

  • Soil roughness


Geological Modeling


Some of the uses include

  • Faults

  • Rock layer

  • Drilling

  • Mineral deposits.


Benefits of PyVista


The following are some important advantages:


  • A really simple tool to learn

  • Great documentation

  • Rendering that provides great results.

  • Ability to create interactive visualizations

  • Graphics of a high quality

  • A community of open-source developers that is thriving

  • Possibility of using sizes of data that are enormous

  • Compatible with the VTK environment

  • Great compatibility with scientific computing

  • Great integration with Jupyter Notebook


Drawbacks of PyVista


Even though we can name a lot of advantages, there are some drawbacks too:


  • There are not many options for GIS analysis.

  • While it is possible to deal with really huge datasets, they require too much memory.

  • Installing the software may be a complicated issue for users of older computers.

  • Customization of rendering is not simple and may require additional knowledge of VTK.

  • PyVista is not developed as a GIS platform.


Common Applications


The applications of PyVista are numerous and include:


  • GIS and geospatial visualization

  • Civil engineering

  • Mechanical engineering

  • Geological modeling

  • Medical imaging

  • CFD simulations

  • Finite element analysis (FEA)

  • Robotics

  • Research of autonomous cars

  • Drone surveying

  • LiDAR processing

  • Environmental sciences

  • Oceanography

  • Weather studies

  • Scientific research


Best Practices


Some best practices from PyVista are as follows:


  • Use NumPy arrays in the workflow.

  • Reduce the size of the meshes before rendering the huge models.

  • Use the correct type of colormaps.

  • Use the available filters instead of developing new ones.

  • Use off-screen rendering for server-automated workflows.

  • Use PyVista with Jupyter Notebooks.


PyVista is a great library for scientific 3D visualization in Python, as it makes the power of VTK available via a clear API. You can use it to visualize terrain maps, LiDAR point clouds, finite element simulations, medical imaging, or engineering meshes at a professional level and with the minimum coding effort.


For professionals working in GIS, data scientists, engineers, and researchers, PyVista strikes a good balance between ease of use, performance, and flexibility. The library's compatibility with other scientific tools makes PyVista one of the best libraries for contemporary visualization workflows.


To learn more about PyVista and its geospatial capabilities, click here.


For more information or any questions regarding the LizardTech suite of products, please don't hesitate to contact us at:



USA (HQ): (720) 702–4849


(A GeoWGS84 Corp Company)



Comments


bottom of page