I’ve recently been working on
pyvista-xarray to create a
DataArray accessor that builds a direct line of interoperability between xarray and VTK/PyVista for 3D visualization.
This package is still in its early stages and I’d love to solicit as much feedback as possible from the xarray community about the types of data and ways in which you all would like to see this package improve to address 3D visualization needs.
Additionally, this package provides a DataSet IO backend for reading VTK files with xarray’s
Please open an issue for any feedback you have or any new features you’d like to see!
Check out the README of the repository for examples, usage, and installation instructions: GitHub - pyvista/pyvista-xarray: PyVista DataArray accessors for xarray
import pvxarray import rioxarray da = rioxarray.open_rasterio("Elevation.tif") da = da.rio.reproject("EPSG:3857") # Grab the mesh object for use with PyVista mesh = da.pyvista.mesh(x="x", y="y") # Warp top and plot in 3D mesh.warp_by_scalar().plot()
Or open a VTK data file with xarray
import xarray as xr import pyvista as pv ds = xr.open_dataset("knee.vti", engine="pyvista") # Generate PyVista mesh object mesh = ds["SLCImage"].pyvista.mesh(x="x", y="y", z="z") # Slice and plot mesh.slice_orthogonal().plot()
(would add screenshot but I’m too new of a user )