I have a VTK file and I can open that using pyvista
. When I open this file in any 3D viewer applicatoins (e.g. Paraview) I can see the points and their values (there are many points distributed in X,Y,Z and each point has its own value).
In pyvista
I can only see the points coordinates and don't know how to access the values (or labels) at each coordinate.
import pyvista as pv
pd = pv.read('data.vtk')
pd.points
# UnstructuredGrid (0x20fef143e28)
# N Cells: 0
# N Points: 80851
# X Bounds: -2.570e+03, 2.550e+03
# Y Bounds: -1.280e+03, 1.280e+03
# Z Bounds: -1.075e+03, 2.048e+02
# N Arrays: 0
You're referring to the
point_arrays
property, which you can use to access scalars associated with each point.If you've assigned a value to each point within a mesh, you can access it with the
point_arrays
property, which behaves like a python dictionary. For example, when generating aSphere
withinpyvista
, the normals are included with the mesh and can be accessed with:See the Basic API Usage for more details.