Gridded Data¶
Gridded datasets in pyvista capture vtkRectilinearGrid
and vtkImageData
data objects on the VTK backend. These data types have common features which
are encompassed int their shared inheritance of pyvista.Grid
Attributes
Return a length 3 tuple of the grid’s dimensions. 
Methods

class
pyvista.
Grid
(*args, **kwargs)¶ Bases:
pyvista.core.dataset.DataSet
A class full of common methods for nonpointset grids.

property
dimensions
¶ Return a length 3 tuple of the grid’s dimensions.
These are effectively the number of nodes along each of the three dataset axes.

property
Rectilinear Grid¶
Attributes
Return a length 3 tuple of the grid’s dimensions. 

Return a meshgrid of numpy arrays for this mesh. 

Return a copy of the points as an n by 3 numpy array. 

Get the coordinates along the Xdirection. 

Get the coordinates along the Ydirection. 

Get the coordinates along the Zdirection. 
Methods
Cast this rectilinear grid to a 

class
pyvista.
RectilinearGrid
(*args, **kwargs)¶ Bases:
vtkmodules.vtkCommonDataModel.vtkRectilinearGrid
,pyvista.core.grid.Grid
Extend the functionality of a vtk.vtkRectilinearGrid object.
Can be initialized in several ways:
Create empty grid
Initialize from a vtk.vtkRectilinearGrid object
Initialize directly from the point arrays
See _from_arrays in the documentation for more details on initializing from point arrays
Examples
>>> import pyvista >>> import vtk >>> import numpy as np
>>> # Create empty grid >>> grid = pyvista.RectilinearGrid()
>>> # Initialize from a vtk.vtkRectilinearGrid object >>> vtkgrid = vtk.vtkRectilinearGrid() >>> grid = pyvista.RectilinearGrid(vtkgrid)
>>> # Create from NumPy arrays >>> xrng = np.arange(10, 10, 2) >>> yrng = np.arange(10, 10, 5) >>> zrng = np.arange(10, 10, 1) >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)

cast_to_structured_grid
()¶ Cast this rectilinear grid to a
pyvista.StructuredGrid
.

property
dimensions
¶ Return a length 3 tuple of the grid’s dimensions.
These are effectively the number of nodes along each of the three dataset axes.

property
meshgrid
¶ Return a meshgrid of numpy arrays for this mesh.
This simply returns a
numpy.meshgrid
of the coordinates for this mesh inij
indexing. These are a copy of the points of this mesh.

property
points
¶ Return a copy of the points as an n by 3 numpy array.

property
x
¶ Get the coordinates along the Xdirection.

property
y
¶ Get the coordinates along the Ydirection.

property
z
¶ Get the coordinates along the Zdirection.
Uniform Grid¶
PyVista’s definition of a uniform grid is an extension of VTK’s vtkImageData
Attributes
Return the origin of the grid (bottom southwest corner). 

Build a copy of the implicitly defined points as a numpy array. 

Get the spacing for each axial direction. 

Return all the X points. 

Return all the Y points. 

Return all the Z points. 
Methods
Cast this uniform grid to a 

Cast this uniform grid to a 

class
pyvista.
UniformGrid
(*args, **kwargs)¶ Bases:
vtkmodules.vtkCommonDataModel.vtkImageData
,pyvista.core.grid.Grid
,pyvista.core.filters.UniformGridFilters
Extend the functionality of a vtk.vtkImageData object.
Can be initialized in several ways:
Create empty grid
Initialize from a vtk.vtkImageData object
Initialize directly from the point arrays
See
_from_specs
in the documentation for more details on initializing from point arraysExamples
>>> import pyvista >>> import vtk >>> import numpy as np
>>> # Create empty grid >>> grid = pyvista.UniformGrid()
>>> # Initialize from a vtk.vtkImageData object >>> vtkgrid = vtk.vtkImageData() >>> grid = pyvista.UniformGrid(vtkgrid)
>>> # Using just the grid dimensions >>> dims = (10, 10, 10) >>> grid = pyvista.UniformGrid(dims)
>>> # Using dimensions and spacing >>> spacing = (2, 1, 5) >>> grid = pyvista.UniformGrid(dims, spacing)
>>> # Using dimensions, spacing, and an origin >>> origin = (10, 35, 50) >>> grid = pyvista.UniformGrid(dims, spacing, origin)

cast_to_rectilinear_grid
()¶ Cast this uniform grid to a
pyvista.RectilinearGrid
.

cast_to_structured_grid
()¶ Cast this uniform grid to a
pyvista.StructuredGrid
.

property
origin
¶ Return the origin of the grid (bottom southwest corner).

property
points
¶ Build a copy of the implicitly defined points as a numpy array.

property
spacing
¶ Get the spacing for each axial direction.

property
x
¶ Return all the X points.

property
y
¶ Return all the Y points.

property
z
¶ Return all the Z points.