Convert VTI File to Numpy Array in Python Programming

Suppose I have a vti file containing a scalar field (such as velocity) and its corresponding spatial coordinates (x, y, z coordinates), how should I read the vti file using Python programming and convert the vtil file to a numpy array in Python programming?

1 Like

You should check out the vtki Python package. It provides a NumPy interface back to all VTK data objects.

Installation is simply

pip install vtki

Then in Python, reading your file is simply:

import vtki
data =‘my_file.vti’)
# Get points as NumPy array
points = data.points

Please see this series of blog posts on using VTK and numpy for a thorough overview on how to do this.